Skip to content

Commit cae5bb4

Browse files
authored
Update typescript.md - middleware order (#2558)
Change in the description of the order of middleware.
1 parent 11cc9c3 commit cae5bb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/guides/typescript.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ const useBearStore = create<BearState>()(
208208
)
209209
```
210210

211-
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.
211+
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.
212212

213213
## Authoring middlewares and advanced usage
214214

0 commit comments

Comments
 (0)