mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
45 lines
886 B
JavaScript
45 lines
886 B
JavaScript
'use strict';
|
|
|
|
var pkg = require('./package');
|
|
var React = require('react-native');
|
|
var {
|
|
AppRegistry,
|
|
StyleSheet,
|
|
Text,
|
|
View,
|
|
} = React;
|
|
|
|
var CodePush = require('react-native-code-push');
|
|
|
|
var UpdateOnStart = React.createClass({
|
|
componentDidMount: function() {
|
|
CodePush.checkForUpdate().done((update) => {
|
|
if (update && update.downloadUrl) {
|
|
update.download().done((newPackage) => {
|
|
newPackage.install();
|
|
});
|
|
}
|
|
});
|
|
},
|
|
render: function() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<Text>
|
|
Welcome to {pkg.name} {pkg.version}!
|
|
</Text>
|
|
</View>
|
|
);
|
|
}
|
|
});
|
|
|
|
var styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#F5FCFF',
|
|
}
|
|
});
|
|
|
|
AppRegistry.registerComponent('UpdateOnStart', () => UpdateOnStart);
|