'Trying to call multiple dispatchers on useffect
I'm trying to call multiple dispatchers on useEffect from extraReducers, this way seems not to work. How can I call two or more dispatchers differently?
I call this from a functional component:
useEffect(() => {
dispatch(getCourseOneAsync())
dispatch(getCourseTwoAsync())
}, [dispatch]);
Here are the reducers:
extraReducers: {
[getCourseOneAsync.fulfilled]: (state, action) => {
return action.payload.courses;
},
[getCourseTwoAsync.fulfilled]: (state, action) => {
return action.payload.courses2;
}
Solution 1:[1]
From my point, the function inside dispatch and the name of extraReducer should be the same. I edited)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mukhriddin Shakhriyorov |
