-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Description and goal
In #5583, we had to disabled the ImmutableStateInvariantMiddleware check because the store was too big and the check took too much time. This check was used to guarantee that the store was immutable, and was fired each time the store changed (could take up to 270ms).
This check is only done on dev environment, it is deactivated on production.
To solve the warning, we had 2 quick solutions with ImmutableStateInvariantMiddleware:
- either increase the threshold from 32ms to 300ms approx (but not good for the perf)
- either deactivate the middleware
We chose to deactivate it as we use Immer to create our store slices and it improve the perfs (see reduxjs/redux-toolkit#415 (comment) and reduxjs/redux-toolkit#415 (comment)).
But nothing guarantees now that the store is immutable, we could do for instance:
const a = store.getState();
a.user = {};
To replace the check, possible solutions to evaluate:
- make the root state an object.freeze object
- use a new lib to check that each time we create the store, it is immutable
Acceptance criteria
A new technical solution is found to guarantee the immutability of the store.