-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Description
In my CRUD app, I am using same form component and same state for the form in redux for add and edit. When I call the API for fetching data using Promises for edit and before the response arrives, we change our route to "Add" form, all the form data will be auto filled for add item since i am using the same state for both add and edit. Is there any way to prevent this from happening?
my action creator:
fetchById: function (entity, id) {
return function (dispatch) {
dispatch(apiActions.apiRequest(entity));
return (apiUtil.fetchById(entity, id).then(function (response) {
dispatch(apiActions.apiResponse(entity));
dispatch(actions.selectItem(entity, response.body));
}
}
}
As response is late, "selectItem" is dispatched late. And when I open form for adding item, this form is filled with the data from response.
Metadata
Metadata
Assignees
Labels
No labels