出于性能原因,我希望清除state.routes
并仅保留currentRoute
和prevRoutes
。我把索引总是放在1上。
但我的问题是幻灯片动画被删除了:(
我的代码:
const navReducer = (state, action) => {
const nextState = AppNavigator.router.getStateForAction(action, state);
switch (action.type) {
case 'Navigation/NAVIGATE':
const newState = nextState || state;
const routes = newState.routes;
const routesCount = routes.length;
if (routesCount > 2) {
const newRoutes = routes.slice(-2);
return { ...newState, ...{ routes: newRoutes, index: 1 } };
}
break;
case 'Navigation/BACK':
console.log('Push back');
break;
default:
break;
}
return nextState || state;
};
任何人都知道我是否可以清除state.routes
,但保存默认导航动画?
谢谢!