einmal icon indicating copy to clipboard operation
einmal copied to clipboard

Bug: Actions are dispatched twice

Open omardoma opened this issue 5 years ago • 1 comments

https://github.com/incipher/einmal/blob/fba4caaa0b0e8b7b762f365d1f8a6d4ac9f1ecd5/src/hooks/useGlobalState/reducer.ts#L27

The actions are being dispatched twice because the useReducer callback is always a new function, it can be solved by making the reduction function a function declaration/expression and passing its reference instead of inlining it.

See Here: https://www.reddit.com/r/reactjs/comments/av39fs/usereducer_action_dispatched_twice/

omardoma avatar Jun 23 '20 02:06 omardoma

@omardoma Great catch, thanks a lot!

itsabdelrahman avatar Jun 23 '20 23:06 itsabdelrahman