Pārlūkot izejas kodu

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

Artal Druk 8 gadus atpakaļ
vecāks
revīzija
2059e54aea
1 mainītis faili ar 20 papildinājumiem un 4 dzēšanām
  1. 20
    4
      src/Navigation.js

+ 20
- 4
src/Navigation.js Parādīt failu

@@ -29,12 +29,20 @@ function _registerComponentNoRedux(screenID, generator) {
29 29
 
30 30
       constructor(props) {
31 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 43
       render() {
36 44
         return (
37
-          <InternalComponent navigator={this.navigator} {...this.allProps} />
45
+          <InternalComponent navigator={this.navigator} {...this.state.internalProps} />
38 46
         );
39 47
       }
40 48
     };
@@ -52,13 +60,21 @@ function _registerComponentRedux(screenID, generator, store, Provider) {
52 60
 
53 61
       constructor(props) {
54 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 74
       render() {
59 75
         return (
60 76
           <Provider store={store}>
61
-            <InternalComponent navigator={this.navigator} {...this.allProps} />
77
+            <InternalComponent navigator={this.navigator} {...this.state.internalProps} />
62 78
           </Provider>
63 79
         );
64 80
       }