Created
April 24, 2020 16:26
-
-
Save DJanoskova/95381f94273a6c403e60f52f2df98f65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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