File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
2024 Prep/machine_coding/react/src Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
import './App.css'
2
- import { CounterWithReducer } from './components'
2
+ import { ReRender } from './components'
3
3
4
4
function App ( ) {
5
5
return (
6
6
< div className = "container" >
7
7
< h1 > Vite + React</ h1 >
8
- < CounterWithReducer />
8
+ < ReRender />
9
9
</ div >
10
10
)
11
11
}
Original file line number Diff line number Diff line change
1
+ import { useState } from 'react'
2
+
3
+ export default function ReRender ( ) {
4
+ console . log ( 'Rerendered....' )
5
+ const [ name , setName ] = useState ( 'prathamesh' )
6
+ const [ age , setAge ] = useState ( 21 )
7
+
8
+ return (
9
+ < div >
10
+ < h1 > Rerender</ h1 >
11
+ < h2 > Hello { name } </ h2 >
12
+ < h2 > My age is { age } </ h2 >
13
+ < button onClick = { ( ) => setName ( 'prathamesh' ) } > Update name</ button >
14
+ < button onClick = { ( ) => setAge ( 22 ) } > Update age</ button >
15
+ </ div >
16
+ )
17
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import CountDownTimer from './Timer'
6
6
import LiftingUpState from './LiftingStateUp'
7
7
import InputHookComp from './InputCustomHookComp'
8
8
import CounterWithReducer from './CounterWithReducer'
9
+ import ReRender from './ReRender'
9
10
10
11
export {
11
12
Loader ,
@@ -16,4 +17,5 @@ export {
16
17
LiftingUpState ,
17
18
InputHookComp ,
18
19
CounterWithReducer ,
20
+ ReRender ,
19
21
}
You can’t perform that action at this time.
0 commit comments