Redux Thunk vs Redux Saga - what is the difference?
Both handle async in Redux differently.
Redux Thunk
Simple: dispatch functions.
```javascript // Action creator returns function const fetchUser = (id) => async (dispatch) => { dispatch({ type: 'FETCH_USER_REQUEST' });
try { const user = await api.getUser(id); dispatch({ type: 'FETCH_USER_SUCCESS', payload: user }); } catch (error) { dispatch({ type: 'FETCH_USER_FAILURE', error }); } };
// Usage dispatch(fetchUser(123)); ```
Redux Saga
Powerful: generator functions.
```javascript import { call, put, takeLatest } from 'redux-saga/effects';
function* fetchUser(action) { try { const user = yield call(api.getUser, action.payload); yield put({ type: 'FETCH_USER_SUCCESS', payload: user }); } catch (error) { yield put({ type: 'FETCH_USER_FAILURE', error }); } }
function* watchFetchUser() { yield takeLatest('FETCH_USER_REQUEST', fetchUser); } ```
Comparison
| Feature | Thunk | Saga |
|---|---|---|
| Learning curve | Easy | Steep |
| Async handling | Promises | Generators |
| Cancellation | Hard | Built-in |
| Testing | Harder | Easier |
| Debouncing | Manual | Built-in |
| Best for | Simple | Complex |
When Use What
Thunk: Simple API calls Saga: Complex workflows
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.