Skip to content

Instantly share code, notes, and snippets.

@danielkcz
Created September 6, 2017 12:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkcz/b79b9d09c72e60bd1e89238e25e23387 to your computer and use it in GitHub Desktop.
Save danielkcz/b79b9d09c72e60bd1e89238e25e23387 to your computer and use it in GitHub Desktop.
Update Expo app
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