如何在本机的导航抽屉中调用类函数?

时间:2019-01-08 06:56:27

标签: react-native

我想在抽屉打开和抽屉关闭事件上调用类函数,因为我是React Native的新手,有人可以帮助我吗?

    const defaultGetStateForAction =Drawer.router.getStateForAction;
    Drawer.router.getStateForAction = (action, state) => {

if(state && action.type === 'Navigation/OPEN_DRAWER' ) {
  Alert.alert("drawerOpen")
    //here call a class function with true value
}

if(state && action.type === 'Navigation/DRAWER_CLOSED') {
  Alert.alert("drawerClose")
    //here call a class function  with false value
}

1 个答案:

答案 0 :(得分:1)

使用以下代码解决您的问题

enter image description here