Which of the following scenarios will trigger a re-render in React?
const App = () => {
const [count, setCount] = React.useState(0);
const handleClick = () => setCount(count + 1);
return (
<div>
<button onClick={handleClick}>Increment</button>
<p>{count}</p>
</div>
);
};
When the state count changes.
When the setCount function is called.
Both when the state changes and when setCount is called.
Only when setCount is called.
This question is part of this quiz :
Working of React