Mid
From PDF
React
React.js
How do you handle side effects in Redux?
✅ Using middleware, such as:
- redux-thunk – lets you dispatch functions
- redux-saga – handles complex side effects via generators
- redux-observable – uses RxJS
✅ Example with thunk:
const fetchData = () => async (dispatch) => {
const response = await fetch('/data');
const data = await response.json();
dispatch({ type: 'SET_DATA', payload: data });
};
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png