Ver código fonte

fix Authorized Promise render recreating (#987)

* fix Authorized Promise render

* fix style Authorized blank line
guowenfh 7 anos atrás
pai
commit
69cb402f9d
1 arquivos alterados com 11 adições e 3 exclusões
  1. 11 3
      src/components/Authorized/PromiseRender.js

+ 11 - 3
src/components/Authorized/PromiseRender.js

@@ -6,9 +6,17 @@ export default class PromiseRender extends React.PureComponent {
     component: null,
   };
   componentDidMount() {
-    const ok = this.checkIsInstantiation(this.props.ok);
-    const error = this.checkIsInstantiation(this.props.error);
-    this.props.promise
+    this.setRenderComponent(this.props);
+  }
+  componentWillReceiveProps(nextProps) {
+    // new Props enter
+    this.setRenderComponent(nextProps);
+  }
+  // set render Component : ok or error
+  setRenderComponent(props) {
+    const ok = this.checkIsInstantiation(props.ok);
+    const error = this.checkIsInstantiation(props.error);
+    props.promise
       .then(() => {
         this.setState({
           component: ok,