Closed qkreltms closed 3 years ago
I think we should change middleware on reducer to before dispatching action. because of Link
const actions = {
increase: () => {
middleware({ type: "INCREASE", payload: 1 });
return dispatch({ type: "INCREASE", payload: 1 });
},
substract: () => {
middleware({ type: "SUB", payload: 1 });
return dispatch({ type: "SUB", payload: 1 });
}
};
https://codesandbox.io/s/simple-react-context-example-2-forked-elys2?file=/src/index.js:749-1039
Fun fact redux is ok to dispatching an another action in action, but Context API is not.(May occurs unexpected behavior)
I think we can support context API to listen an action which using
useReducer
by attaching custom middleware.