From 8e987d99aa4c16b3c148c895ac90ddb6800a7467 Mon Sep 17 00:00:00 2001 From: Devansh Jethmalani Date: Fri, 19 Aug 2022 04:18:00 +0530 Subject: [PATCH] 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 --- docs/typescript.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/typescript.md b/docs/typescript.md index e9119ed2..20b1adcc 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -190,6 +190,8 @@ const useBearStore = create()( ) ``` +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 Imagine you had to write this hypothetical middleware...