Questions:
How does useEffect work?
This question is the understand your way of managing side effects in React as it is very crucial.
Sample Answer:
The useEffect executes after the component is rendered to the users. It is used for side effects like fetching data, subscribing to services or updating DOM.
useEffect(() => {
document.title = 'You did ${count} clicks';
}, [count]);
The dependency array (“[count]”) tells React to re-run the effect only when “count” changes.