This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var pkg = require ( './package' ) ;
4
+ var React = require ( 'react-native' ) ;
5
+ var {
6
+ AppRegistry,
7
+ StyleSheet,
8
+ Text,
9
+ View,
10
+ } = React ;
11
+ var Button = require ( 'react-native-button' ) ;
12
+
13
+ var CodePush = require ( 'react-native-code-push' ) ;
14
+
15
+ var UpdateButton = React . createClass ( {
16
+ getInitialState : function ( ) {
17
+ return { } ;
18
+ } ,
19
+ componentDidMount : function ( ) {
20
+ CodePush . checkForUpdate ( ) . done ( ( update ) => {
21
+ if ( update && ! update . downloadURL ) {
22
+ this . setState ( {
23
+ update : update
24
+ } ) ;
25
+ }
26
+ } ) ;
27
+ } ,
28
+ update : function ( ) {
29
+ this . state . update . download ( ) . done ( ( newPackage ) => {
30
+ newPackage . apply ( ) ;
31
+ } ) ;
32
+ } ,
33
+ render : function ( ) {
34
+ var updateButton = null ;
35
+ if ( this . state . update ) {
36
+ updateButton = < Button onPress = { this . update } > Update</ Button > ;
37
+ }
38
+
39
+ return (
40
+ < View style = { styles . container } >
41
+ < Text >
42
+ Welcome to { pkg . name } { pkg . version } !
43
+ </ Text >
44
+ { updateButton }
45
+ </ View >
46
+ ) ;
47
+ }
48
+ } ) ;
49
+
50
+ var styles = StyleSheet . create ( {
51
+ container : {
52
+ flex : 1 ,
53
+ justifyContent : 'center' ,
54
+ alignItems : 'center' ,
55
+ backgroundColor : '#F5FCFF' ,
56
+ }
57
+ } ) ;
58
+
59
+ AppRegistry . registerComponent ( 'UpdateButton' , ( ) => UpdateButton ) ;
You can’t perform that action at this time.
0 commit comments