Skip to content

Conversation

@amsterdamharu
Copy link

Dispatch has a different reference every time you call createDispatch.
That is not how React.useReducer works and this should have consistant behavior.

Reference to issiue: #4

Dispatch has a different reference every time you call createDispatch.
That is not how React.useReducer works and this should have consistant behavior.
@ahungrynoob
Copy link

@Tsourdox
Copy link

Tsourdox commented Jun 28, 2020

Why not just use the useRef hook to solve this? This PR seems overly complicated to me, maybe I'm missing something.

const { current: dispatch } = useRef(action =>
    Object.keys(combinedReducers)		
       .map(key => combinedReducers[key][1])		
       .forEach(fn => fn(action));
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants