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:
Wonsuk Choi 2025-06-25 11:17:14 +09:00 committed by GitHub
parent 5bc717b663
commit e639587da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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),
}))
```