Browse Source

Fix missing props (#2179)

Fix props loading from PropsRegistry in custom buttons
Guy Carmeli 7 years ago
parent
commit
b3d7092ff6
No account linked to committer's email address
2 changed files with 8 additions and 2 deletions
  1. 2
    2
      src/Navigation.js
  2. 6
    0
      src/deprecated/platformSpecificDeprecated.android.js

+ 2
- 2
src/Navigation.js View File

36
       constructor(props) {
36
       constructor(props) {
37
         super(props);
37
         super(props);
38
         this.state = {
38
         this.state = {
39
-          internalProps: {...props, ...PropRegistry.load(props.screenInstanceID)}
39
+          internalProps: {...props, ...PropRegistry.load(props.screenInstanceID || props.passPropsKey)}
40
         }
40
         }
41
       }
41
       }
42
 
42
 
43
       componentWillReceiveProps(nextProps) {
43
       componentWillReceiveProps(nextProps) {
44
         this.setState({
44
         this.setState({
45
-          internalProps: {...PropRegistry.load(this.props.screenInstanceID), ...nextProps}
45
+          internalProps: {...PropRegistry.load(this.props.screenInstanceID || this.props.passPropsKey), ...nextProps}
46
         })
46
         })
47
       }
47
       }
48
 
48
 

+ 6
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

2
 import React, {Component} from 'react';
2
 import React, {Component} from 'react';
3
 import ReactNative, {AppRegistry, NativeModules, processColor} from 'react-native';
3
 import ReactNative, {AppRegistry, NativeModules, processColor} from 'react-native';
4
 import _ from 'lodash';
4
 import _ from 'lodash';
5
+import PropRegistry from './../PropRegistry';
5
 
6
 
6
 import Navigation from './../Navigation';
7
 import Navigation from './../Navigation';
7
 
8
 
331
       if (button.buttonColor) {
332
       if (button.buttonColor) {
332
         button.color = processColor(button.buttonColor);
333
         button.color = processColor(button.buttonColor);
333
       }
334
       }
335
+      if (button.component) {
336
+        const passPropsKey = _.uniqueId('customButtonComponent');
337
+        PropRegistry.save(passPropsKey, button.passProps);
338
+        button.passProps = {passPropsKey};
339
+      }
334
     });
340
     });
335
   }
341
   }
336
   let leftButton = getLeftButton(params);
342
   let leftButton = getLeftButton(params);