This is how I solved the Loading Screen. I worked with Navigator Component.
In my index.android.js
I set the initialRoute
to my SplashPage/SplashScreen class and then in there I set a timeout which links to the MainView you want to jump to after a certain time.
My Navigator in index.android.js:
<Navigator
initialRoute={{id: 'SplashPage'}}
renderScene={this.renderScene}
configureScene={(route) => {
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.HorizontalSwipeJump;
}}
/>
My initialRoute Class:
class SplashPage extends Component {
componentWillMount () {
var navigator = this.props.navigator;
setTimeout (() => {
navigator.replace({
id: 'MainView', <-- This is the View you go to
});
}, 2000); <-- Time until it jumps to "MainView"
}
render () {
return (
<View style={{flex: 1, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center'}}>
<Image style={{position: 'absolute', left: 0, top: 0, width: windowSize.width, height: windowSize.height}} source={require('image!splash_screen')}></Image>
</View>
);
}
}
module.exports = SplashPage;
EDIT
Might be more interesting because it is "native" ;)
https://github.com/crazycodeboy/react-native-splash-screen
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…