Created
September 6, 2017 12:59
-
-
Save danielkcz/b79b9d09c72e60bd1e89238e25e23387 to your computer and use it in GitHub Desktop.
Update Expo app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
import { Util } from 'expo' | |
export default class App extends React.Component { | |
state = { | |
updated: false, | |
} | |
componentWillMount() { | |
Util.addNewVersionListenerExperimental(() => { | |
this.setState({ updated: true }) | |
setTimeout(() => Util.reload(), 10000) | |
}) | |
} | |
render() { | |
if (this.state.updated) { | |
return (<View style={styles.container}> | |
<Text>App update available, reloading in 10 seconds...</Text> | |
</View>) | |
} | |
return ( | |
<View style={styles.container}> | |
<Text>App is running...</Text> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment