发布带有React Navigation v2的Expo在发布后返回AppLoading

时间:2018-07-15 13:11:54

标签: react-native react-navigation expo

我有一个带有Expo和React Navigation的React Native应用程序。每当用户之前是否登录时,我都使用createSwitchNavigator在Auth屏幕和Home屏幕之间切换,这是代码:

const RootStackNavigator = createSwitchNavigator({
  Auth: AuthStack, 
  Home: HomeStack,
  AuthLoading: AuthLoading
}, {
  initialRouteName: 'AuthLoading'
});

这是AuthLoading:

class AuthLoading extends React.Component {
  constructor(props) {
    super(props);
    this._bootstrapAsync();
  }

  _bootstrapAsync = async () => {
    const userToken = await AsyncStorage.getItem('userToken');
    this.props.navigation.navigate(userToken ? 'Home' : 'Auth');
  } 

  render() {
    return (
      <Container style={{ alignItems: 'center' }}>
        <Expo.AppLoading />
        <StatusBar barStyle='default' />
      </Container>
    );
  }
}

该应用程序在本地正常运行,但是当我用expo发布它时,它卡在了iOS和android的Expo.AppLoading Screen中。我不知道为什么,请帮忙!

0 个答案:

没有答案