Recall & Review
beginner
What happens in React when you update a component's state using
useState?React schedules a re-render of that component. The component function runs again, and React updates the UI to reflect the new state.
Click to reveal answer
intermediate
Does React re-render a component if the state value is set to the same value it already has?
No. React compares the new state with the current state using Object.is. If they are the same, React skips the re-render to improve performance.
Click to reveal answer
beginner
Why should you avoid directly mutating state in React?
Direct mutation does not change the state reference, so React may not detect a change and skip re-rendering. Always use the state setter function to update state immutably.
Click to reveal answer
intermediate
How does React batch multiple state updates inside event handlers?
React groups multiple state updates in event handlers into one re-render to improve performance, so the component only re-renders once after all updates.
Click to reveal answer
beginner
What is the role of
useEffect in relation to state changes and re-rendering?useEffect runs after the component renders. It can react to state changes to perform side effects like fetching data or updating the DOM outside React.Click to reveal answer
What triggers a React component to re-render?
✗ Incorrect
Only updating the component's state with the setter function triggers React to re-render that component.
If you call the state setter with the same value as current state, what happens?
✗ Incorrect
React compares the new and current state and skips re-render if they are the same to optimize performance.
Why is it important to avoid mutating state directly?
✗ Incorrect
Direct mutation does not change the state reference, so React may not detect the change and skip re-rendering.
How does React handle multiple state updates inside an event handler?
✗ Incorrect
React batches multiple state updates inside event handlers to re-render only once for better performance.
When does
useEffect run in relation to state changes?✗ Incorrect
useEffect runs after the component renders and can respond to state changes to perform side effects.Explain how React decides when to re-render a component after a state update.
Think about how React checks if the state really changed before re-rendering.
You got /4 concepts.
Describe how React batches multiple state updates and why this is useful.
Imagine updating your shopping list several times quickly and React only updating the screen once.
You got /4 concepts.