Skip to content

Instantly share code, notes, and snippets.

@DJanoskova
Last active May 11, 2020 00:28
Show Gist options
  • Select an option

  • Save DJanoskova/ed6127e138ec94c9559ff4e2a71ec919 to your computer and use it in GitHub Desktop.

Select an option

Save DJanoskova/ed6127e138ec94c9559ff4e2a71ec919 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
const Form = () => {
const [name, setName] = useState('');
const handleChange = e => {
setName(e.target.value);
}
const handleSubmit = () => {
// api call here
}
return (
<div>
<input type="text" onChange={handleChange} value={name} />
<button type="button" onClick={handleSubmit}>
Submit
</button>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment