Bläddra i källkod

Fixes button react component props

yogevbd 6 år sedan
förälder
incheckning
caff3b8801
3 ändrade filer med 21 tillägg och 0 borttagningar
  1. 8
    0
      e2e/ScreenStyle.test.js
  2. 7
    0
      lib/ios/RNNTopBarOptions.m
  3. 6
    0
      playground/src/screens/ScrollViewScreen.js

+ 8
- 0
e2e/ScreenStyle.test.js Visa fil

@@ -115,6 +115,14 @@ describe('screen style', () => {
115 115
     await expect(elementByLabel(`Two`)).toExist();
116 116
   });
117 117
 
118
+  test(':ios: pass props to custom button component should exist after screen rerender', async () => {
119
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
120
+    await expect(elementByLabel(`Two`)).toExist();
121
+    await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
122
+    await elementById(testIDs.POP_BUTTON).tap();
123
+    await expect(elementByLabel(`Two`)).toExist();
124
+  });
125
+
118 126
   test('tab bar items visibility', async () => {
119 127
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
120 128
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();

+ 7
- 0
lib/ios/RNNTopBarOptions.m Visa fil

@@ -153,6 +153,9 @@ extern const NSInteger BLUR_TOPBAR_TAG;
153 153
 		_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:(RNNRootViewController*)viewController];
154 154
 		[_navigationButtons applyLeftButtons:self.leftButtons rightButtons:self.rightButtons defaultLeftButtonStyle:self.leftButtonStyle defaultRightButtonStyle:self.rightButtonStyle];
155 155
 	}
156
+	
157
+	self.rightButtons = nil;
158
+	self.leftButtons = nil;
156 159
 }
157 160
 
158 161
 - (void)setRightButtonColor:(NSNumber *)rightButtonColor {
@@ -184,6 +187,8 @@ extern const NSInteger BLUR_TOPBAR_TAG;
184 187
 		} else {
185 188
 			[_rightButtonStyle mergeWith:rightButtons];
186 189
 		}
190
+	} else {
191
+		_rightButtons = rightButtons;
187 192
 	}
188 193
 }
189 194
 
@@ -196,6 +201,8 @@ extern const NSInteger BLUR_TOPBAR_TAG;
196 201
 		} else {
197 202
 			[_leftButtonStyle mergeWith:leftButtons];
198 203
 		}
204
+	} else {
205
+		_leftButtons = leftButtons;
199 206
 	}
200 207
 }
201 208
 

+ 6
- 0
playground/src/screens/ScrollViewScreen.js Visa fil

@@ -37,6 +37,7 @@ class ScrollViewScreen extends Component {
37 37
       topBarHideOnScroll: false
38 38
     };
39 39
     this.onClickToggleTopBarHideOnScroll = this.onClickToggleTopBarHideOnScroll.bind(this);
40
+    this.onClickPop = this.onClickPop.bind(this);
40 41
   }
41 42
 
42 43
   render() {
@@ -45,6 +46,7 @@ class ScrollViewScreen extends Component {
45 46
         <ScrollView testID={testIDs.SCROLLVIEW_ELEMENT} contentContainerStyle={styles.contentContainer}>
46 47
           <View>
47 48
             <Button title='Toggle Top Bar Hide On Scroll' testID={testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL} onPress={this.onClickToggleTopBarHideOnScroll} />
49
+            <Button title='Pop screen' testID={testIDs.POP_BUTTON} onPress={this.onClickPop} />
48 50
           </View>
49 51
         </ScrollView>
50 52
       </View>
@@ -57,6 +59,10 @@ class ScrollViewScreen extends Component {
57 59
     });
58 60
   }
59 61
 
62
+  onClickPop() {
63
+    Navigation.pop(this.props.componentId);
64
+  }
65
+
60 66
   componentDidUpdate() {
61 67
     Navigation.mergeOptions(this.props.componentId, {
62 68
       topBar: {