File tree 1 file changed +9
-12
lines changed
1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 8
8
9
9
const state = { eventCount : 0 , username : '' }
10
10
11
- function increment ( ) {
12
- setState ( { eventCount : state . eventCount + 1 } )
13
- }
11
+ function App ( ) {
12
+ function handleClick ( ) {
13
+ setState ( { eventCount : state . eventCount + 1 } )
14
+ }
14
15
15
- function updateUsername ( event ) {
16
- setState ( {
17
- username : event . target . value ,
18
- } )
19
- }
16
+ function handleChange ( event ) {
17
+ setState ( { username : event . target . value } )
18
+ }
20
19
21
- function App ( ) {
22
20
return (
23
21
< div >
24
22
< p > There have been { state . eventCount } events.</ p >
25
23
< p >
26
- < button onClick = { increment } > Click Me</ button >
24
+ < button onClick = { handleClick } > Click Me</ button >
27
25
</ p >
28
26
< p > You typed: { state . username } </ p >
29
27
< p >
30
- < input onBlur = { updateUsername } />
28
+ < input onChange = { handleChange } />
31
29
</ p >
32
30
</ div >
33
31
)
43
41
}
44
42
45
43
renderApp ( )
46
- setState ( { eventCount : 10 } )
47
44
</ script >
48
45
</ body >
You can’t perform that action at this time.
0 commit comments