Closed lili21 closed 3 years ago
import create from 'zustand'; const useStore = create(set => ({ test: { name: 'lili', age: 10 }, update: () => set({ test: { age: 11 }}) })
the expected result state is test: { name: 'lili', age: 11}。
test: { name: 'lili', age: 11}
quick answer:
set(state => ({ test: { ...state.test, age: 11 } }))
produce
the expected result state is
test: { name: 'lili', age: 11}
。