我在这个过程中我传递的webapp做出反应的阵营原生版本。componentWillReceiveProps在阵营本土VS ReactJS
在本地做出反应,我有这样的登录页面。我正在使用react-navigation。
componentWillReceiveProps(nextProps) {
const { requestStatus, currentUser } = nextProps
const getUserInProgress = get(requestStatus, GET_MY_DETAILS, true)
if (!getUserInProgress) {
if (currentUser) {
currentUser.verified_mobile ? this.props.navigation.navigate('Dashboard') : this.props.navigation.navigate('VerifyMobile')
} else if (!currentUser) {
console.log('not logged in')
}
}
}
因此,在登录页面上,它会获取用户详细信息并检查移动设备是否已通过验证,如果没有,则会验证移动页面。
在验证移动页面,当调用时,在登录页面此componentWillReceiveProps仍然运行,即使它不是当前的活动页面。
我在ReactJS相同的逻辑/代码和它的行为完全不同。
React Native是否正常?
编辑:
让我澄清我的问题是什么。
当我不是在登录页上,我是验证移动页面上。 componentWillReceiveProps仍在运行,尽管该页面在历史记录中。这在我构建reactjs应用程序时没有发生。它只发生在原生应用程序中。所以我想知道这是否是历史堆栈中页面的正常行为来运行其componentWillReceiveProps?
可否请您详细说明您经历了什么行为以及错误的具体情况? –
是的,它仍然在堆栈中,所以它仍然存在。它只是没有显示。 – WilomGfx