Parcourir la source

Implement passProps for TopTab screens

Guy Carmeli il y a 8 ans
Parent
révision
0d26eb34c5

+ 17
- 25
example-redux/src/app.js Voir le fichier

@@ -70,43 +70,35 @@ export default class App {
70 70
             topTabs: [
71 71
               {
72 72
                 screenId: 'example.ListScreen',
73
-                title: 'Tab1'
73
+                title: 'Tab1',
74
+                 passProps: {
75
+                   str: 'This is a prop passed to Tab1'
76
+                 }
74 77
               },
75 78
               {
76 79
                 screenId: 'example.PushedScreen',
77
-                title: 'Tab2'
80
+                title: 'Tab2',
81
+                passProps: {
82
+                  str: 'This is a prop passed to Tab2'
83
+                }
84
+
78 85
               },
79 86
               {
80 87
                 screenId: 'example.PushedScreen',
81
-                title: 'Tab3'
88
+                title: 'Tab3',
89
+                passProps: {
90
+                  str: 'This is a prop passed to Tab3'
91
+                }
82 92
               },
83 93
               {
84 94
                 screenId: 'example.FirstTabScreen',
85
-                title: 'Tab4'
95
+                title: 'Tab4',
96
+                passProps: {
97
+                  str: 'This is a prop passed to Tab4'
98
+                }
86 99
               }
87 100
             ],
88 101
             navigatorStyle: {}
89
-          },
90
-          passProps: {
91
-            str: 'This is a prop passed in \'startSingleScreenApp()\'!',
92
-            obj: {
93
-              str: 'This is a prop passed in an object!',
94
-              arr: [
95
-                {
96
-                  str: 'This is a prop in an object in an array in an object!'
97
-                }
98
-              ],
99
-              arr2: [
100
-                [
101
-                  'array of strings',
102
-                  'with two strings'
103
-                ],
104
-                [
105
-                  1, 2, 3
106
-                ]
107
-              ]
108
-            },
109
-            num: 1234
110 102
           }
111 103
         });
112 104
         return;

+ 2
- 2
example-redux/src/screens/FirstTabScreen.js Voir le fichier

@@ -134,8 +134,8 @@ class FirstTabScreen extends Component {
134 134
 
135 135
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
136 136
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
137
-        <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
138
-        <Text style={{fontWeight: '500'}}>Array prop: {this.props.obj.arr[0].str}</Text>
137
+        {this.props.obj ? <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text> : false}
138
+        {this.props.obj && this.props.obj.arr ? <Text style={{fontWeight: '500'}}>Array prop: {this.props.obj.arr[0].str}</Text> : false}
139 139
       </View>
140 140
     );
141 141
   }

+ 4
- 4
example-redux/src/screens/PushedScreen.js Voir le fichier

@@ -67,7 +67,7 @@ class PushedScreen extends Component {
67 67
 
68 68
   render() {
69 69
     return (
70
-      <View style={{flex: 1, padding: 20, backgroundColor: this.bgColor}}>
70
+      <ScrollView style={{flex: 1, padding: 20, backgroundColor: this.bgColor}}>
71 71
 
72 72
         <Text style={styles.text}>
73 73
           <Text style={{fontWeight: '500'}}>Counter: </Text> {this.props.counter.count}
@@ -117,10 +117,10 @@ class PushedScreen extends Component {
117 117
 
118 118
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
119 119
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
120
-        <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
121
-        <Text style={{fontWeight: '500'}}>Array prop: {this.props.obj.arr[0].str}</Text>
120
+        {this.props.obj ? <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text> : false}
121
+        {this.props.obj && this.props.obj.arr ? <Text style={{fontWeight: '500'}}>Array prop: {this.props.obj.arr[0].str}</Text> : false}
122 122
 
123
-      </View>
123
+      </ScrollView>
124 124
     );
125 125
   }
126 126