如何在contentComponent中检测DrawerClose

时间:2018-10-11 13:51:53

标签: react-native react-navigation

我有contentComponent:DrawerContainer

在DrawerContainer中,我现在有一个按钮,我想每次用户关闭抽屉时都检查文本

通过使用以下代码,我可以获取DrawerClose,但我不知道如何将其传递给contentComponent:DrawerContainer

const defaultGetStateForAction = DrawerStack.router.getStateForAction;

DrawerStack.router.getStateForAction = (action, state) => {
    //use 'DrawerOpen' to capture drawer open event
    if (state && action.type === 'Navigation/NAVIGATE' && action.routeName === 'DrawerClose') {
        console.log('DrawerClose')
    }
    return defaultGetStateForAction(action, state);
};

0 个答案:

没有答案