Q20 Observe the below code snippet. What will be the value of {counter.count} when the button is clicked 5 times const R

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

Q20 Observe the below code snippet. What will be the value of {counter.count} when the button is clicked 5 times const R

Post by answerhappygod »

Q20 Observe The Below Code Snippet What Will Be The Value Of Counter Count When The Button Is Clicked 5 Times Const R 1
Q20 Observe The Below Code Snippet What Will Be The Value Of Counter Count When The Button Is Clicked 5 Times Const R 1 (85.33 KiB) Viewed 27 times
React Js Questions
Q20 Observe the below code snippet. What will be the value of {counter.count} when the button is clicked 5 times const RenderCounter = () => { const [age, setAge] = useState(0) const counter = useRef(0); const handleClick = () => { setAge(age + 1) } useEffect(0 => { counter.current = counter.current + 1; },0) return <div className="container"> <h1>{counter.current}</h1> <h1>{age}</h1> <button onClick={0 => handleClick()}>Click</button> </div> ); }; a) 0 b) 1 c) 5 d) Error as age is not passed as a dependency to useEffect method Q21 Consider an online application developed using React where the customer can buy Laptops. There is a new requirement where the buyer can customize their purchase by adding or removing the features. Each feature has a price associated. In order to add the above requirement to the application. Which of the following is the best option ? 11/14 a) useReducer Hook b) Custom Hook c) Hoc d) None of the above
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply