questions
Predict the output of the below code snippet when start button is clicked. const AppComp = () => { const counter = useRef(0); const startTimer = () => { setInterval(( => { console.log('from interval, ', counter.current) counter.current += 1; }, 1000) } return <div>{counter.current}</div> <button onClick={startTimer}>Start</button> a) Both console and dom will be updated with new value every second b) No change in console and dom c) Console will be updated every second, but dom value will remain at 0 d) Error
React Js Predict the output of the below code snippet when start button is clicked. const AppComp = () => { const counter = useRe
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am