File tree 1 file changed +20
-25
lines changed
1 file changed +20
-25
lines changed Original file line number Diff line number Diff line change 1
- import React , { useState } from ' react' ;
2
- import ReactDOM from ' react-dom' ;
1
+ import React , { useState } from " react"
2
+ import { createRoot } from " react-dom/client"
3
3
4
4
const Counter = ( ) => {
5
- const [ count , setCount ] = useState ( 0 ) ;
5
+ const [ count , setCount ] = useState ( 0 )
6
6
7
- increment = ( ) => {
8
- setCount ( prevCount => prevCount + 1 ) ;
9
- } ;
7
+ const increment = ( ) => {
8
+ setCount ( prevCount => prevCount + 1 )
9
+ }
10
10
11
- return (
12
- < div id = "mainArea" >
13
- < p >
14
- Button Count:
15
- < span > { count } </ span >
16
- </ p >
17
- < button
18
- onClick = { increment }
19
- id = "mainButton"
20
- >
21
- Increase
22
- </ button >
23
- </ div >
24
- ) ;
25
- } ;
11
+ return (
12
+ < div id = "mainArea" >
13
+ < p >
14
+ { `Button Count: ` }
15
+ < span > { count } </ span >
16
+ </ p >
17
+ < button onClick = { increment } id = "mainButton" >
18
+ Increase
19
+ </ button >
20
+ </ div >
21
+ )
22
+ }
26
23
27
- ReactDOM . render (
28
- < Counter /> ,
29
- document . getElementById ( 'root' )
30
- ) ;
24
+ const root = createRoot ( document . getElementById ( "root" ) )
25
+ root . render ( < Counter /> )
You can’t perform that action at this time.
0 commit comments