State Management · Junior · Question 34 of 75

How do you read just one field from a Zustand store?

const useStore = create((set) => ({ count: 0, user: null, inc: () => {} }));

Explanation

A selector subscribes the component only to count: changes to user won't re-render it. Calling useStore() without a selector subscribes to the whole store and re-renders on any change.

Further reading

Problem with a question

State Management · Junior · question 34

Test yourself

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

Take this quiz