Analytics Vidhya
Published in

Analytics Vidhya

Dispatching asynchronous Side Effects inside synchronous Redux actions without using any middleware — React.

Photo by NeONBRAND on Unsplash
export const resetFilter = () => async (dispatch, getState) => {   
dispatch({ type: RESET_FILTER });
await dispatch(callAPI_1());
const {
mainComponent: { api1_data },
} = getState();
await dispatch(
callAPI_2(api1_data.param1, api1_data.param2)
);
};
useEffect(() => {
async function getData() {
await callAPI_1();
await callAPI_2(api1_data.param1, api1_data.param2);
}
getData();
}, [callAPI_1]);

Subhayan Ghosh

--

--

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Subhayan Ghosh

Engineering & Product| Writes about Data and Full Stack optimizations | Building for the Web