答案 0 :(得分:2)
您必须修改您的减速器才能进行推送。你需要做的是 -
现在你所要做的就是用克隆状态更新你的状态。
case PUSH_ROUTE:{
// trying to push the route where we already are, no need to change a thing
if (state.routes[state.index].key === (action.route && action.route.key))
return state;
// ensure no duplicate keys
const index = state.routes.findIndex((route) => {
return action.route.key === route.key && action.route.title ===route.title;
});
if (index > -1) {
const clonedState = Object.assign({}, state);
clonedState.routes.splice(index, 1);
return NavigationStateUtils.push(clonedState, action.route);
}
// normal case for a push
return NavigationStateUtils.push(state, action.route);
}