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

Duplicate Reducer Method Invokation #53

Open zlanich opened 3 years ago

zlanich commented 3 years ago

Hey there! I'm reporting a bug that seems to have also appeared in use-immer.

When invoking a reducer function, it fires twice initially, but it appears that it does not modify the state twice.

I've reproduced it in CodeSandbox: https://codesandbox.io/s/immer-reducer-duplicate-invokation-iylwj

use-immer Issue: https://github.com/immerjs/use-immer/issues/11

The solution seemed to have something to do with the need to memo a produce()'d reducer, or something along those lines.

Thanks!