Redux saga method is being called twice in React native application.
Please find
saga.ts
export function* fetchValueLable(action: IFluxStandardAction<ILables>) {
try {
if (!action.payload) {
return;
}
const response = yield call(serviceClass.getLables, payload);
if (response.success && response.lines != null) {
yield put(Actions.fetchLableSuccess(AvailableLables));
} else {
}
} catch (e) {
yield put(Actions.fetchLableFailure(e.message));
}
}
function* watchLable() {
yield takeLatest(FfsActionTypes.FETCH_LABEL, fetchValueLable);
}
export const LableSaga = {
watchLable,
};
Please find redux configurations
const configureStore = (): Store<IState> => {
// Redux configurations
const middleware = [];
const enhancers = [];
const sagaMiddleware = createSagaMiddleware();
middleware.push(sagaMiddleware);
const storeConfig: Store<IState> = createStore(rootReducer, compose(...enhancers));
sagaMiddleware.run(rootSaga);
return storeConfig;
};
StoreProviderService.init(configureStore);
const store = StoreProviderService.getStore();
from Component level , dispatch action part
return bindActionCreators({
fetchLableValue,
},
dispatch);
};
export default connect(mapStateToProps, mapDispatchToProps)(component);
Please let me know how i can fix this duplicate saga calls.