react导航的DrawerNavigator在drawer close上调用什么函数
DrawerNavigator of react navigation call what function on drawer close
我想在抽屉时派发一个动作close.But我不知道我需要写什么功能,你能帮我吗
您需要自定义导航操作才能知道 DrawerClose
事件 fired.Here 是一个简单的示例:
const MyAppDrawerNavigator = DrawerNavigator({
//...
});
const defaultGetStateForAction = MyAppDrawerNavigator.router.getStateForAction;
MyAppDrawerNavigator.router.getStateForAction = (action, state) => {
if (state && action.type === 'Navigation/NAVIGATE' && action.routeName === 'DrawerClose') {
console.log('DrawerClose');
//dispatch whatever action you want
}
return defaultGetStateForAction(action, state);
};
要了解有关如何自定义路由器的更多信息,请参阅 here。
我想在抽屉时派发一个动作close.But我不知道我需要写什么功能,你能帮我吗
您需要自定义导航操作才能知道 DrawerClose
事件 fired.Here 是一个简单的示例:
const MyAppDrawerNavigator = DrawerNavigator({
//...
});
const defaultGetStateForAction = MyAppDrawerNavigator.router.getStateForAction;
MyAppDrawerNavigator.router.getStateForAction = (action, state) => {
if (state && action.type === 'Navigation/NAVIGATE' && action.routeName === 'DrawerClose') {
console.log('DrawerClose');
//dispatch whatever action you want
}
return defaultGetStateForAction(action, state);
};
要了解有关如何自定义路由器的更多信息,请参阅 here。