Predict the output of the below code snippet when start button is clicked. const AppComp = () => { const counter = useRe

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Predict the output of the below code snippet when start button is clicked. const AppComp = () => { const counter = useRe

Post by answerhappygod »

Predict The Output Of The Below Code Snippet When Start Button Is Clicked Const Appcomp Const Counter Usere 1
Predict The Output Of The Below Code Snippet When Start Button Is Clicked Const Appcomp Const Counter Usere 1 (55.78 KiB) Viewed 39 times
React Js 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply