erikras / erikras/react-redux-universal-hot-example
multiple api calls - only one single action.result
- Dominant language
- JavaScript
- Stars
- 12.1k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
i have created a container similar to src/components/InfoBar/InfoBar.js which is connected to a reducer ("posts"). the reducer has the "load" method defined just like info.js reducer "module".
i have verified that all the intended data are retrieved from their respective endpoints.
the issue is that depending on what order the "load" methods are called in src\App\App.js, I get the data from last called "load" method.
src\App\App.js
```
import { isLoaded as isInfoLoaded, load as loadInfo } from 'redux/modules/info';
import { isLoaded as isPostsLoaded, load as getPosts } from 'redux/modules/posts';
import { isLoaded as isAuthLoaded, load as loadAuth, logout } from 'redux/modules/auth';
.......
@asyncConnect([{
promise: ({store: {dispatch, getState}}) => {
const promises = [];
if (!isPostsLoaded(getState())) {
promises.push(dispatch(getPosts()));
}
if (!isInfoLoaded(getState())) {
promises.push(dispatch(loadInfo()));
}
if (!isAuthLoaded(getState())) {
promises.push(dispatch(loadAuth()));
}
return Promise.all(promises);
}
}])
```
Here is my LOAD_SUCCESS defined in info.js and posts.js (a reducer "module" created by me) respectively
```
case LOAD_SUCCESS:
return {
...state,
loading: false,
loaded: true,
data: action.result
};
```
```
case LOAD_SUCCESS:
return {
...state,
posts_loading: false,
posts_loaded: true,
data: action.result
};
```
Here is my current state for "info" and "posts"
http://prntscr.com/e02qxi
Can anyone explain why my api call data replaces the previous api call data? And where can I fix it?
Contributor guide
Assessment
This issue has not been assessed yet.