为什么我的onEnter道具没有被触发? (react-native-router-flux v4)

问题描述 投票:0回答:0

我创建了自己的Scene组件,其条件为onEnter属性。 它检查redux商店,如果你有某些信息,并且应该引导你到正确的场景。 但是,一旦我触发导航到该特定场景,它似乎不会运行甚至不返回控制台日志。

我试过控制台记录类似“嘿我被击中!”。 进入场景后我的控制台保持不变。

const Auth = props => {
    const { component, key, userLoggedIn, hasUserInfo, hasSellerAccount} = props

    const isLoggedIn = (userLoggedIn, hasUserInfo, hasSellerAccount) => {
        if(userLoggedIn && hasUserInfo && hasSellerAccount){
            Actions.admin()
        } else if (userLoggedIn && !hasUserInfo){
            Actions.userInformation()
        } else if (userLoggedIn && hasUserInfo && !hasSellerAccount){
            Actions.createAccount()
        } else if (!userLoggedIn){
            Actions.logIn()
        }
    }
    return(
        <Scene
        key={key}
        onEnter={isLoggedIn(userLoggedIn, hasUserInfo, hasSellerAccount)}
        component={component}
        {...props}
        />
    )
} ```

I expected it to check the conditions and redirect you to the correct page.
react-native react-navigation react-native-router-flux
© www.soinside.com 2019 - 2024. All rights reserved.