State Management · Senior · Question 17 of 75

How do you persist only some fields of a Zustand store and handle schema changes?

Explanation

persist(fn, { name, partialize: (s) => ({ cart: s.cart }), version: 2, migrate: (old, v) => ... }). Without migrations, a renamed field leaves broken data in users' storage.

Further reading

Problem with a question

State Management · Senior · question 17

Test yourself

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

Take this quiz