Open hockeylagu opened 6 years ago
Same problem here ...
Well, same problem, I will have to get rid of Immer then I guess
It would be great if we could support Immer in the future.
Simple work around could be:
import { setAutoFreeze } from "immer"
setAutoFreeze(false)
@hockeylagu taking into account current version of persistStore, I mean states equality check:
if (newState === restState) return state
Your solution provide Immer support without errors and setAutoFreeze(false). Maybe it's not optimal solution but at least we modify already modified state without using Immer inside library.
// run base reducer:
// is state modified ? return original : return updated
let newState = baseReducer(restState, action)
if (newState === restState) return state
else {
newState = {
...newState,
_persist: _persist
}
return conditionalUpdate(newState)
}
Is Immer supported now?
I also need this to work alongside Immer. I've tried every configuration that I can think of... I have opened up #1068
I too would very much appreciate being able to use these 2 great libraries together. It seems wrong to be calling setAutoFreeze(false)
on an immutability library.
Without any further background knowledge, it could maybe be solved by using weakmap, rather than modifying the objects directly?
Op zo 15 sep. 2019 09:46 schreef Alex McMillan notifications@github.com:
I too would very much appreciate being able to use these 2 great libraries together. It seems wrong to be calling setAutoFreeze(false) on an immutability library.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rt2zz/redux-persist/issues/747?email_source=notifications&email_token=AAN4NBDZHROLQBJRJ4ETNELQJXY5FA5CNFSM4ETNXJO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6XMHAI#issuecomment-531547009, or mute the thread https://github.com/notifications/unsubscribe-auth/AAN4NBA2XYQE36X5Y5QESD3QJXY5FANCNFSM4ETNXJOQ .
I use immer to update my state and keep it immutable. Immer has the possibility to auto freeze the state to insure that we don't modify the state, but Redux-Perist modify it at line 153 of persistReducer
My unoptimal solution is to desactivate the freezing or revert the commit of this line to return a new State like that: