mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
docs(README): remove 'omit' in 'Overwriting state' section (#3160)
* docs(README): replace 'lodash' with 'es-toolkit' in 'Overwriting state' section * docs(README): change 'es-tooklit/compat' to 'es-toolkit/compat/omit' * docs(README): replace 'es-toolkit' with custom 'omit' implementation * docs(README): remove 'omit' util function * docs(README): simplify 'deleteTuna'
This commit is contained in:
parent
5bc717b663
commit
e639587da1
@ -125,13 +125,11 @@ const treats = useBearStore(
|
||||
The `set` function has a second argument, `false` by default. Instead of merging, it will replace the state model. Be careful not to wipe out parts you rely on, like actions.
|
||||
|
||||
```jsx
|
||||
import omit from 'lodash-es/omit'
|
||||
|
||||
const useFishStore = create((set) => ({
|
||||
salmon: 1,
|
||||
tuna: 2,
|
||||
deleteEverything: () => set({}, true), // clears the entire store, actions included
|
||||
deleteTuna: () => set((state) => omit(state, ['tuna']), true),
|
||||
deleteTuna: () => set(({ tuna, ...rest }) => rest, true),
|
||||
}))
|
||||
```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user