React native 为什么我的单体道具没有被触发?(react本机路由器流量v4)
我已经使用condition OnNet属性创建了自己的场景组件。如果您有某些信息,它会检查redux商店,并引导您找到正确的场景。然而,一旦我触发到特定场景的导航,它似乎不会运行,甚至不会返回控制台日志 我尝试过控制台日志记录,比如“嘿,我被击中了!”,我的控制台在进入场景时保持不变React native 为什么我的单体道具没有被触发?(react本机路由器流量v4),react-native,react-navigation,react-native-router-flux,React Native,React Navigation,React Native Router Flux,我已经使用condition OnNet属性创建了自己的场景组件。如果您有某些信息,它会检查redux商店,并引导您找到正确的场景。然而,一旦我触发到特定场景的导航,它似乎不会运行,甚至不会返回控制台日志 我尝试过控制台日志记录,比如“嘿,我被击中了!”,我的控制台在进入场景时保持不变 const Auth = props => { const { component, key, userLoggedIn, hasUserInfo, hasSellerAccount} = prop
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.
const Auth=props=>{
const{component,key,userLoggedIn,hasUserInfo,hasSellerAccount}=props
const isLoggedIn=(userLoggedIn、hassuserinfo、hasSellerAccount)=>{
if(userLoggedIn&&hasUserInfo&&hasSellerAccount){
Actions.admin()
}else if(userLoggedIn&!hasUserInfo){
Actions.userInformation()
}else if(userLoggedIn&&hassuserinfo&&hasSellerAccount){
Actions.createAccount()
}如果(!userLoggedIn){
Actions.logIn()
}
}
返回(
)
} ```
我希望它检查条件并将您重定向到正确的页面。
尝试将其修改为oneter={()=>isLoggedIn(userLoggedIn、hassuserinfo、hasSellerAccount)}
。我不确定isLoggedIn会不会像你那样被称呼。相反,尝试在arrow函数中调用函数。