Page 1 of 1

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

Posted: Fri May 20, 2022 9:58 am
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 29 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