Redux Saga方法被称为两次(React Native)
在React Native应用中,Redux Saga方法被称为两次。
请找到
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,
};
请从组件级别找到Redux配置
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();
,调度操作部分
return bindActionCreators({
fetchLableValue,
},
dispatch);
};
export default connect(mapStateToProps, mapDispatchToProps)(component);
请让我知道如何修复此重复的传奇调用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论