esamattis / immer-reducer

Type-safe and terse reducers with Typescript for React Hooks and Redux
http://npm.im/immer-reducer
MIT License
225 stars 15 forks source link

Incompatibility with redux-persist #38

Open skoshy opened 5 years ago

skoshy commented 5 years ago

I'm trying to use immer-reducer with redux-persist, which adds its own _persist key to the state, but it fails with this error in the console.

image

Any ideas how to make the two work nicely together?

esamattis commented 5 years ago

Can you provide code replicating this error?

yrral86 commented 4 years ago

FYI, latest redux-persist (6.0.0) is working with immer for me. They've updated it to no longer mutate the state directly and instead make a new object as suggested in this ticket: https://github.com/rt2zz/redux-persist/issues/747

siarheipashkevich commented 3 years ago

@yrral86 how you confirm that it's working correctly?

yrral86 commented 3 years ago

@siarheipashkevich I was seeing the same error. I updated to redux-persist 6. The error went away. In version 6+ they no longer attempt to mutate the state.

siarheipashkevich commented 3 years ago

@yrral86 but in you case you can modify first level of the store directly.

yrral86 commented 3 years ago

@yrral86 but in you case you can modify first level of the store directly.

I don't know what you mean. I didn't provide any example code, so what do you mean by "in you case"? What are you trying to accomplish?

siarheipashkevich commented 3 years ago

@yrral86 can you please provide an example of code how you are using redux-persist? do you use code splitting for redux reducers?