React Dojo

Search

Search concepts, exercises and quizzes

Quiz

State

10 questions

useState: updates, immutability, batching, and derived state

01Why should you never mutate state directly (e.g., state.count = 5)?
02When do you need to use the functional form setCount(c => c + 1) instead of setCount(count + 1)?
03What does React do if you call setState with exactly the same value the state already has?
04How do you correctly update a field of an object in state?
05What is 'derived state' and when shouldn't you use useState for it?
06What does React 18 guarantee about batching multiple setState calls?
07Do two instances of the same component share their state?
08What is the correct order of the values returned by useState?
09How do you correctly update an array of objects in state?
10When does a React component re-render?
Was this helpful?
Sign in to give feedback