Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save virajkulkarni14/79ce7f50787a6cf47ff99468303a7ba3 to your computer and use it in GitHub Desktop.

Select an option

Save virajkulkarni14/79ce7f50787a6cf47ff99468303a7ba3 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 = e => {
e.preventDefault();
// api call here
}
return (
<form onSubmit={handleSubmit}>
<input type="text" onChange={handleChange} value={name} />
<button type="submit">
Submit
</button>
</form>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment