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 });
};