Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update typescript guide persist examples... #2001

Merged
merged 7 commits into from
Aug 25, 2023
15 changes: 9 additions & 6 deletions docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ interface BearState {

const useBearStore = create<BearState>()(
devtools(
persist((set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}))
persist(
(set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}),
{ name: 'bearStore' }
)
)
)
```
Expand All @@ -190,7 +193,7 @@ Just make sure you are using them immediately inside `create` so as to make the
import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'

const myMiddlewares = (f) => devtools(persist(f))
const myMiddlewares = (f) => devtools(persist(f, { name: 'bearStore' }))

interface BearState {
bears: number
Expand Down Expand Up @@ -351,7 +354,7 @@ const useBearStore = create<
>(devtools(persist((set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
})))
}), { name: 'bearStore' }))
```

### Slices pattern
Expand Down
Loading