From 29419489ed1434b679758972490bef1f347957c6 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:47:41 -0700 Subject: [PATCH] Partially enable immutability check This is useful but makes things slower upon state changes. I think still reasonable to have because: 1. It's only included in dev mode 2. The slowness in dev mode is not too noticeable (50~200ms on my machine) The console warnings hint to disable it if the slowness becomes unbearable. --- src/store.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/store.ts b/src/store.ts index b7100ae11..ae7e9f8f1 100644 --- a/src/store.ts +++ b/src/store.ts @@ -15,10 +15,15 @@ const store = configureStore({ middleware: (getDefaultMiddleware) => // This adds the thunk middleware, and for development builds, other useful checks. getDefaultMiddleware({ - // TODO: Go through reducers and see why the state is not immutable nor serializable. - // These were not checked prior to the adoption of Redux Toolkit, and were not - // investigated to minimize conversion efforts. - immutableCheck: false, + immutableCheck: { + // Immutability can't be checked in the following due to circular references. + ignoredPaths: [ + 'tree.nodes', + 'tree.vaccines', + 'treeToo.nodes', + 'treeToo.vaccines', + ], + }, // By design, the state contains many values that are non-serializable. // Instead of adding several ignoredPaths, disable this check entirely.