Skip to content

Instantly share code, notes, and snippets.

@callezenwaka
Created September 7, 2022 16:20
Show Gist options
  • Save callezenwaka/bdc6d4d0414ed1c6bdd062b7a64c74d1 to your computer and use it in GitHub Desktop.
Save callezenwaka/bdc6d4d0414ed1c6bdd062b7a64c74d1 to your computer and use it in GitHub Desktop.
React two-way data binding
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