You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: the GET_OFFERS type is only there because a type is required on an Action.
The problem comes when I start replaying actions. As soon as I move past the "original" action when moving back, it will duplicate actions. So my app needs 3 actions to start (SET_METADATA, REQUEST_OFFERS and RECEIVE_OFFERS), but as soon as I move back along REQUEST_OFFERS it fires the async actions again. Am I doing something wrong here?
Edit: So I found the underlying issue: when my (connected) root component receives props, if there's metadata (_.size(metadata)), I call the requestOffers action creator. This is intended behavior for my app, but will in the future make it hard to replay state from external sessions. Does anybody have any recommendations how to work around this?
Ok, so I fixed this by moving the SET_METADATA up a level, and only mounting the component which initiates the request if there's metadata. Are there any recommended patterns for this sort of behavior yet? This took me by surprise a bit (Yay I have time travelling! Wait, what?), I wouldn't mind writing some addition to the documentation about this.
The text was updated successfully, but these errors were encountered:
Note: the GET_OFFERS type is only there because a type is required on an Action.
This is a misconception. It is only required by the time an action reaches the reducer. If your middleware interprets the action and instead dispatches other actions, it is only essential that they have types by the time the last middleware in chain dispatches them.
I'm having an issue with my "async" middleware. It follows the pattern of
redux-promise-middleware
in a way, but is tailored to our needs:My ActionCreator then looks like this:
Note: the
GET_OFFERS
type is only there because atype
is required on an Action.The problem comes when I start replaying actions. As soon as I move past the "original" action when moving back, it will duplicate actions. So my app needs 3 actions to start (
SET_METADATA
,REQUEST_OFFERS
andRECEIVE_OFFERS
), but as soon as I move back alongREQUEST_OFFERS
it fires the async actions again. Am I doing something wrong here?Edit: So I found the underlying issue: when my (connected) root component receives props, if there's metadata (
_.size(metadata)
), I call therequestOffers
action creator. This is intended behavior for my app, but will in the future make it hard to replay state from external sessions. Does anybody have any recommendations how to work around this?Here's the code from my component:
Ok, so I fixed this by moving the
SET_METADATA
up a level, and only mounting the component which initiates the request if there's metadata. Are there any recommended patterns for this sort of behavior yet? This took me by surprise a bit (Yay I have time travelling! Wait, what?), I wouldn't mind writing some addition to the documentation about this.The text was updated successfully, but these errors were encountered: