Browse Source

since "allProps" was not being updated, existing props were not receiving prop updates as well

Artal Druk 8 years ago
parent
commit
2059e54aea
1 changed files with 20 additions and 4 deletions
  1. 20
    4
      src/Navigation.js

+ 20
- 4
src/Navigation.js View File

29
 
29
 
30
       constructor(props) {
30
       constructor(props) {
31
         super(props);
31
         super(props);
32
-        this.allProps = {...props, ...PropRegistry.load(props.screenInstanceID)};
32
+        this.state = {
33
+          internalProps: {...props, ...PropRegistry.load(props.screenInstanceID)}
34
+        }
35
+      }
36
+  
37
+      componentWillReceiveProps(nextProps) {
38
+        this.setState({
39
+          internalProps: {...PropRegistry.load(this.props.screenInstanceID), ...nextProps}
40
+        })
33
       }
41
       }
34
 
42
 
35
       render() {
43
       render() {
36
         return (
44
         return (
37
-          <InternalComponent navigator={this.navigator} {...this.allProps} />
45
+          <InternalComponent navigator={this.navigator} {...this.state.internalProps} />
38
         );
46
         );
39
       }
47
       }
40
     };
48
     };
52
 
60
 
53
       constructor(props) {
61
       constructor(props) {
54
         super(props);
62
         super(props);
55
-        this.allProps = {...props, ...PropRegistry.load(props.screenInstanceID)};
63
+        this.state = {
64
+          internalProps: {...props, ...PropRegistry.load(props.screenInstanceID)}
65
+        }
66
+      }
67
+      
68
+      componentWillReceiveProps(nextProps) {
69
+        this.setState({
70
+          internalProps: {...PropRegistry.load(this.props.screenInstanceID), ...nextProps}
71
+        })
56
       }
72
       }
57
 
73
 
58
       render() {
74
       render() {
59
         return (
75
         return (
60
           <Provider store={store}>
76
           <Provider store={store}>
61
-            <InternalComponent navigator={this.navigator} {...this.allProps} />
77
+            <InternalComponent navigator={this.navigator} {...this.state.internalProps} />
62
           </Provider>
78
           </Provider>
63
         );
79
         );
64
       }
80
       }