-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12_state.html
More file actions
32 lines (25 loc) · 915 Bytes
/
Copy path12_state.html
File metadata and controls
32 lines (25 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script src="https://unpkg.com/react@16.12.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.8.3/babel.js"></script>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
const App = () => {
const [name1, setName1] = React.useState('')
const [name2, setName2] = React.useState('')
const setUserNameHandler = (event) => {
setName1(event.target.value)
}
return (
<div>
<p><input id="text1" onChange={setUserNameHandler} /> </p>
<p>You typed: {name1}</p>
<p><input id="text2" onChange={event => setName2(event.target.value)} /> </p>
<p>You typed: {name2}</p>
</div>
)
}
const renderApp = () => ReactDOM.render(<App />, document.getElementById("root"))
renderApp()
</script>