Interview question
What is Redux Saga? Redux Saga क्या है?
Answer
// Redux Saga - side effects management
import { call, put, takeEvery } from 'redux-saga/effects';
function* fetchUserSaga(action) {
try {
const user = yield call(fetchUser, action.payload);
yield put({ type: 'FETCH_USER_SUCCESS', payload: user });
} catch (error) {
yield put({ type: 'FETCH_USER_ERROR', payload: error });
}
}
function* rootSaga() {
yield takeEvery('FETCH_USER_REQUEST', fetchUserSaga);
}Redux Saga side effects को handle करता है।
Generators use करता है।Was this answer clear?