Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throwing error when using redux-multi #43

Closed
rnsloan opened this issue Jun 6, 2016 · 1 comment
Closed

throwing error when using redux-multi #43

rnsloan opened this issue Jun 6, 2016 · 1 comment

Comments

@rnsloan
Copy link

rnsloan commented Jun 6, 2016

#40

This commit added:

if (typeof action.type === 'undefined') {
  throw new Error(
    'Actions may not have an undefined "type" property. ' +
    'Have you misspelled a constant?'
  );
}

This will throw if you are using arrays that redux-multi will handle e.g:

[ 
  { type: 'action1',
    payload: { id: '1234' } 
  },
  { type: 'action2',
    payload: { id: '5678' } 
  } 
]
@dmitry-zaets
Copy link
Collaborator

dmitry-zaets commented Jun 6, 2016

This check is from redux itself. If it will not work here - then it will not also work with redux.

But it will work and will not give an error, because when you are using redux-multi middleware - it just dispatches each single action from array separately:

function multi ({dispatch}) {
  return next => action =>
    Array.isArray(action)
      ? action.filter(Boolean).map(dispatch)
      : next(action)
}

Code from code of redux-multi

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

No branches or pull requests

2 participants