Created
September 7, 2022 16:20
-
-
Save callezenwaka/bdc6d4d0414ed1c6bdd062b7a64c74d1 to your computer and use it in GitHub Desktop.
React two-way data binding
This file contains 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 logo from "./logo.svg"; | |
import "./App.css"; | |
import { useState } from "react"; | |
function App() { | |
const [food, setFood] = useState("dumpling"); | |
return ( | |
<div className="App"> | |
<input | |
type="text" | |
value={food} | |
onChange={(event) => { | |
const value = event.target.value; | |
setFood(value); | |
}} | |
></input> | |
{food} | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment