mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
Update typescript.md - middleware order (#2558)
Change in the description of the order of middleware.
This commit is contained in:
parent
11cc9c3c5e
commit
cae5bb48bc
@ -208,7 +208,7 @@ const useBearStore = create<BearState>()(
|
||||
)
|
||||
```
|
||||
|
||||
Also, we recommend using `devtools` middleware as last as possible. For example, when you use it with `immer` as a middleware, it should be `immer(devtools(...))` and not `devtools(immer(...))`. This is because`devtools` mutates the `setState` and adds a type parameter on it, which could get lost if other middlewares (like `immer`) also mutate `setState` before `devtools`. Hence using `devtools` at the end makes sure that no middlewares mutate `setState` before it.
|
||||
Also, we recommend using `devtools` middleware as last as possible. For example, when you use it with `immer` as a middleware, it should be `devtools(immer(...))` and not `immer(devtools(...))`. This is because`devtools` mutates the `setState` and adds a type parameter on it, which could get lost if other middlewares (like `immer`) also mutate `setState` before `devtools`. Hence using `devtools` at the end makes sure that no middlewares mutate `setState` before it.
|
||||
|
||||
## Authoring middlewares and advanced usage
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user