promiseReducer.js 331 B

1234567891011121314
  1. function promiseReducer(state, { type, name, status, payload, error }) {
  2. if (!state) {
  3. return {}; //{status , payload , error}
  4. }
  5. if (type === "PROMISE") {
  6. return {
  7. ...state,
  8. [name]: { status, payload, error },
  9. };
  10. }
  11. return state;
  12. }
  13. export default promiseReducer;