Skip to content

Commit 9b23bc4

Browse files
committed
feat: 🎸 added rerender question
1 parent c89efa4 commit 9b23bc4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

2024 Prep/machine_coding/react/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import './App.css'
2-
import { CounterWithReducer } from './components'
2+
import { ReRender } from './components'
33

44
function App() {
55
return (
66
<div className="container">
77
<h1>Vite + React</h1>
8-
<CounterWithReducer />
8+
<ReRender />
99
</div>
1010
)
1111
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

2024 Prep/machine_coding/react/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import CountDownTimer from './Timer'
66
import LiftingUpState from './LiftingStateUp'
77
import InputHookComp from './InputCustomHookComp'
88
import CounterWithReducer from './CounterWithReducer'
9+
import ReRender from './ReRender'
910

1011
export {
1112
Loader,
@@ -16,4 +17,5 @@ export {
1617
LiftingUpState,
1718
InputHookComp,
1819
CounterWithReducer,
20+
ReRender,
1921
}

0 commit comments

Comments
 (0)