From 69cb402f9d4ca72933eafbc9294a860fb1d62991 Mon Sep 17 00:00:00 2001 From: guowenfh Date: Wed, 28 Feb 2018 10:36:08 +0800 Subject: [PATCH] fix Authorized Promise render recreating (#987) * fix Authorized Promise render * fix style Authorized blank line --- src/components/Authorized/PromiseRender.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index 22f1fcb7..43a4fa9e 100644 --- a/src/components/Authorized/PromiseRender.js +++ b/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, -- GitLab