You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+46-7Lines changed: 46 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,8 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
133
133
134
134
***Option 1: Wrap your root component with the `codePush` higher-order component:**
135
135
136
+
* For class component
137
+
136
138
```javascript
137
139
importcodePushfrom"react-native-code-push";
138
140
@@ -142,10 +144,23 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
142
144
MyApp =codePush(MyApp);
143
145
```
144
146
147
+
* For functional component
148
+
149
+
```javascript
150
+
import codePush from "react-native-code-push";
151
+
152
+
let MyApp: () => React$Node = () => {
153
+
}
154
+
155
+
MyApp = codePush(MyApp);
156
+
```
157
+
145
158
***Option 2: Use the [ES7 decorator](https://github.com/wycats/javascript-decorators) syntax:**
146
159
147
160
*NOTE: Decorators are not yet supported in Babel 6.x pending proposal update.* You may need to enable it by installing and using [babel-preset-react-native-stage-0](https://github.com/skevy/babel-preset-react-native-stage-0#babel-preset-react-native-stage-0).
148
161
162
+
* For classcomponent
163
+
149
164
```javascript
150
165
import codePush from "react-native-code-push";
151
166
@@ -154,18 +169,42 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
154
169
}
155
170
```
156
171
172
+
* For functional component
173
+
174
+
```javascript
175
+
import codePush from "react-native-code-push";
176
+
177
+
const MyApp: () => React$Node = () => {
178
+
}
179
+
180
+
export default codePush(MyApp);
181
+
```
182
+
157
183
By default, CodePush will check for updates on every app start. If an update is available, it will be silently downloaded, and installed the next time the app is restarted (either explicitly by the end user or by the OS), which ensures the least invasive experience for your end users. If an available update is mandatory, then it will be installed immediately, ensuring that the end user gets it as soon as possible.
158
184
159
185
If you would like your app to discover updates more quickly, you can also choose to sync up with the CodePush server every time the app resumes from the background.
160
186
161
-
```javascript
162
-
let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME };
187
+
* For classcomponent
163
188
164
-
class MyApp extends Component {
165
-
}
189
+
```javascript
190
+
let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME };
166
191
167
-
MyApp = codePush(codePushOptions)(MyApp);
168
-
```
192
+
class MyApp extends Component {
193
+
}
194
+
195
+
MyApp = codePush(codePushOptions)(MyApp);
196
+
```
197
+
198
+
* For functional component
199
+
200
+
```javascript
201
+
let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME };
202
+
203
+
let MyApp: () => React$Node = () => {
204
+
}
205
+
206
+
MyApp = codePush(codePushOptions)(MyApp);
207
+
```
169
208
170
209
Alternatively, if you want fine-grained control over when the check happens (like a button press or timer interval), you can call [`CodePush.sync()`](docs/api-js.md#codepushsync) at any time with your desired `SyncOptions`, and optionally turn off CodePush's automatic checking by specifying a manual `checkFrequency`:
171
210
@@ -186,7 +225,7 @@ class MyApp extends Component {
0 commit comments