Olá, estou com dificuldades com a versão 2 da biblioteca, fico preso na splash screen (tela branca). Gostaria de saber o que estou fazendo errado. Segue o código:
package.json
"dependencies":
...
"react": "16.5.0",
"react-native": "0.57.0",
"react-native-navigation": "^2.0.2641",
...
},
app.js
export default () => {
Navigation.registerComponent('Login', () => Login);
Navigation.registerComponent('Main', () => Main);
AsyncStorage.getItem('token')
.then(token => {
if(token) {
return {
name: 'Main',
options: {
topBar: {
title: {
text: 'Dashboard'
}
}
}
};
}
return {
name: 'Login',
options: {
topBar: {
hidden: true,
},
statusBar: {
style: 'dark'
}
}
};
})
.then(screen => {
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
stack: {
children: [
{
component: screen
}
],
}
}
});
});
});
}
Login.js
AsyncStorage.setItem('token', token);
AsyncStorage.setItem('user', this.state.user);
this.props.navigator.setStackRoot(this.props.componentId, {
component: {
name: 'Main',
options: {
topBar: {
title: {
text: 'Dashboard'
}
}
}
}
})
Main.js
this.props.navigator.push(this.props.componentId, {
component: {
name: 'Detail',
options: {
topBar: {
title: {
text: 'Details'
}
}
}
}
})