redux-utilities / redux-promise

FSA-compliant promise middleware for Redux.
MIT License
2.67k stars 134 forks source link

Extra fields in action creator breaks detection of promise(?) #27

Open oltsa opened 8 years ago

oltsa commented 8 years ago

I bumped into a problem and i'm not sure if it's because of axios or this middleware, but when I'm trying to return an updated array of elements, I need to pass index to the reducer

return {
  type: ActionTypes.SOMETHING,
  payload: promiseInstance,
  index,
}

either it's not detecting it or i'm doing something wrong (bets on the ladder) as with only type and payload I can hook into with with .then from the component where I dispatch the action, but with adding extra field I cannot

adriancooney commented 8 years ago

redux-promise depends on flux-standard-actions's isFSA method which defines a standard action to have four valid keys: type, payload, error, meta. Since your promise uses the payload property (otherwise redux-promise won't detect it), you have to stick the index into the meta object on the action.

return {
  type: ActionTypes.SOMETHING,
  payload: promiseInstance,
  meta: { index }
}
oltsa commented 8 years ago

Aah thank you!