fix(docs/typescript): provide example how to use middlewares with #1565 (#1578)

This commit is contained in:
Holger Grosse-Plankermann 2023-01-27 01:00:31 +01:00 committed by GitHub
parent 1023eb4af4
commit 04080fdedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -467,6 +467,23 @@ export const BearComponent = () => {
}
```
If you want to use middlewares with your store:
```ts
import { createStore } from 'zustand/vanilla'
import { devtools } from 'zustand/middleware'
export const vanillaBearStore = createStore<BearState>()(
devtools((set, getState) => ({
...initialBearState,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}))
)
```
For more information about why there are extra parentheses,
please see the [Basic usage section](#basic-usage).
## Middlewares and their mutators reference
- `devtools``["zustand/devtools", never]`