Explorar el Código

Use bound functions in WelcomeScreen

Guy Carmeli hace 6 años
padre
commit
8524f36067
Se han modificado 1 ficheros con 13 adiciones y 26 borrados
  1. 13
    26
      playground/src/screens/WelcomeScreen.js

+ 13
- 26
playground/src/screens/WelcomeScreen.js Ver fichero

@@ -17,19 +17,6 @@ class WelcomeScreen extends Component {
17 17
       }
18 18
     };
19 19
   }
20
-  constructor(props) {
21
-    super(props);
22
-    this.onClickPush = this.onClickPush.bind(this);
23
-    this.onClickShowModal = this.onClickShowModal.bind(this);
24
-    this.onClickLifecycleScreen = this.onClickLifecycleScreen.bind(this);
25
-    this.onClickPushOptionsScreen = this.onClickPushOptionsScreen.bind(this);
26
-    this.onClickPushExternalComponent = this.onClickPushExternalComponent.bind(this);
27
-    this.onClickPushOrientationMenuScreen = this.onClickPushOrientationMenuScreen.bind(this);
28
-    this.onClickBackHandler = this.onClickBackHandler.bind(this);
29
-    this.onClickPushTopTabsScreen = this.onClickPushTopTabsScreen.bind(this);
30
-    this.onClickShowStaticLifecycleOverlay = this.onClickShowStaticLifecycleOverlay.bind(this);
31
-    this.onClickProvidedId = this.onClickProvidedId.bind(this);
32
-  }
33 20
 
34 21
   render() {
35 22
     return (
@@ -53,7 +40,7 @@ class WelcomeScreen extends Component {
53 40
     );
54 41
   }
55 42
 
56
-  onClickSwitchToTabs() {
43
+  onClickSwitchToTabs = () => {
57 44
     Navigation.setRoot({
58 45
       bottomTabs: {
59 46
         children: [
@@ -123,7 +110,7 @@ class WelcomeScreen extends Component {
123 110
     });
124 111
   }
125 112
 
126
-  onClickSwitchToSideMenus() {
113
+  onClickSwitchToSideMenus = () => {
127 114
     Navigation.setRoot({
128 115
       sideMenu: {
129 116
         left: {
@@ -223,7 +210,7 @@ class WelcomeScreen extends Component {
223 210
     });
224 211
   }
225 212
 
226
-  async onClickPush() {
213
+  onClickPush = async () => {
227 214
     await Navigation.push(this.props.componentId, {
228 215
       component: {
229 216
         name: 'navigation.playground.PushedScreen',
@@ -236,7 +223,7 @@ class WelcomeScreen extends Component {
236 223
     });
237 224
   }
238 225
 
239
-  async onClickPushExternalComponent() {
226
+  onClickPushExternalComponent = async () => {
240 227
     await Navigation.push(this.props.componentId, {
241 228
       externalComponent: {
242 229
         name: 'RNNCustomComponent',
@@ -254,7 +241,7 @@ class WelcomeScreen extends Component {
254 241
     });
255 242
   }
256 243
 
257
-  onClickLifecycleScreen() {
244
+  onClickLifecycleScreen = () => {
258 245
     Navigation.push(this.props.componentId, {
259 246
       component: {
260 247
         name: 'navigation.playground.LifecycleScreen'
@@ -262,7 +249,7 @@ class WelcomeScreen extends Component {
262 249
     });
263 250
   }
264 251
 
265
-  onClickShowStaticLifecycleOverlay() {
252
+  onClickShowStaticLifecycleOverlay = () => {
266 253
     Navigation.showOverlay({
267 254
       component: {
268 255
         name: 'navigation.playground.StaticLifecycleOverlay'
@@ -270,7 +257,7 @@ class WelcomeScreen extends Component {
270 257
     });
271 258
   }
272 259
 
273
-  async onClickShowModal() {
260
+  onClickShowModal = async () => {
274 261
     await Navigation.showModal({
275 262
       stack: {
276 263
         children: [
@@ -284,11 +271,11 @@ class WelcomeScreen extends Component {
284 271
     });
285 272
   }
286 273
 
287
-  onClickShowRedbox() {
274
+  onClickShowRedbox = () => {
288 275
     undefined();
289 276
   }
290 277
 
291
-  onClickPushOptionsScreen() {
278
+  onClickPushOptionsScreen = () => {
292 279
     Navigation.push(this.props.componentId, {
293 280
       component: {
294 281
         name: 'navigation.playground.OptionsScreen',
@@ -299,7 +286,7 @@ class WelcomeScreen extends Component {
299 286
     });
300 287
   }
301 288
 
302
-  onClickPushTopTabsScreen() {
289
+  onClickPushTopTabsScreen = () => {
303 290
     Navigation.push(this.props.componentId, {
304 291
       topTabs: {
305 292
         children: [
@@ -367,7 +354,7 @@ class WelcomeScreen extends Component {
367 354
     });
368 355
   }
369 356
 
370
-  onClickBackHandler() {
357
+  onClickBackHandler = () => {
371 358
     Navigation.push(this.props.componentId, {
372 359
       component: {
373 360
         name: 'navigation.playground.BackHandlerScreen'
@@ -375,7 +362,7 @@ class WelcomeScreen extends Component {
375 362
     });
376 363
   }
377 364
 
378
-  onClickPushOrientationMenuScreen() {
365
+  onClickPushOrientationMenuScreen = () => {
379 366
     Navigation.push(this.props.componentId, {
380 367
       component: {
381 368
         name: 'navigation.playground.OrientationSelectScreen'
@@ -383,7 +370,7 @@ class WelcomeScreen extends Component {
383 370
     });
384 371
   }
385 372
 
386
-  onClickProvidedId() {
373
+  onClickProvidedId = () => {
387 374
     Navigation.showModal({
388 375
       stack: {
389 376
         children: [