在我的本机应用程序中,我想检查用户是否已登录,然后将其重定向到仪表板,否则重定向到登录页面。它正在工作,但是在重定向到仪表板之前,它会短暂显示登录页面。我想避免这个屏幕闪烁并将用户发送到仪表板而不显示登录页面。我在 login.js 中使用 ComponentWillMOunt,如下所示
componentWillMount() {
AsyncStorage.getItem('session', (err, session) => {
console.log(session);
if (session == 'ok') {
this.props.navigation.dispatch(NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'DashboardTab' })
]
}))
}
})
}
This is my App.js for the nav-
const App = StackNavigator({
Home: { screen: LoginScreen },
Register: { screen: RegisterScreen },
Profile: { screen:ProfileScreen },
Wallets: { screen:WalletsScreen },
DashboardAccept: { screen:DashboardAccept },
TermsConditions: { screen:TermsConditionsScreen },
DashboardTab: { screen:DashboardTabScreen },
});
export default App;
请帮忙