State Management · Middle · Question 20 of 75

Why does this component re-render on every store change?

const { count, inc } = useStore();

Explanation

useStore() returns the whole state object, so any change re-renders the component. Select what you need: useStore((s) => s.count) and useStore((s) => s.inc).

Further reading

Problem with a question

State Management · Middle · question 20

Test yourself

Take the State Management · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz