docs(typescript): add recommendation to use devtools after immer (#1198)

* docs(typescript): add recommendation to use `devtools` after `immer`

* remove typo

* run prettier

Co-authored-by: daishi <daishi@axlight.com>
This commit is contained in:
Devansh Jethmalani 2022-08-19 04:18:00 +05:30 committed by GitHub
parent c60a535a46
commit 8e987d99aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,6 +190,8 @@ const useBearStore = create<BearState>()(
) )
``` ```
Also it's recommended to use `devtools` middleware as last as possible, in particular after `immer` middleware, ie it should be `immer(devtools(...))` and not `devtools(immer(...))`. The reason being that `devtools` mutates the `setState` and adds a type parameter on it, which could get lost if other middlewares (like `immer`) mutate `setState` before `devtools`.
## Authoring middlewares and advanced usage ## Authoring middlewares and advanced usage
Imagine you had to write this hypothetical middleware... Imagine you had to write this hypothetical middleware...