From 89cb4c4502dea8a58c28746e4fe2f92b2140f275 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Sat, 27 May 2017 02:45:59 +0700 Subject: [PATCH] Resolve infinite loop --- .../client/components/SignUpContent.js | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/plugins/coral-plugin-auth/client/components/SignUpContent.js b/plugins/coral-plugin-auth/client/components/SignUpContent.js index fd885d1fe..2c0cf1f31 100644 --- a/plugins/coral-plugin-auth/client/components/SignUpContent.js +++ b/plugins/coral-plugin-auth/client/components/SignUpContent.js @@ -7,12 +7,17 @@ import {Button, TextField, Spinner, Success, Alert} from 'coral-ui'; const lang = new I18n(translations); class SignUpContent extends React.Component { - constructor() { - super(); - this.state = { - successfulSignup: false - }; + componentWillReceiveProps(next) { + if ( + !this.props.emailVerificationEnabled && + !this.props.auth.successSignUp && + next.auth.successSignUp + ) { + setTimeout(() => { + this.props.changeView('SIGNIN'); + }, 2000); + } } render() { @@ -28,19 +33,6 @@ class SignUpContent extends React.Component { fetchSignUpFacebook } = this.props; - const beforeSignup = !auth.isLoading && !auth.successSignUp; - const successfulSignup = !auth.isLoading && auth.successSignUp; - - // the first time we render a successfulSignup, trigger a timer - if (this.successfulSignup ^ successfulSignup && !emailVerificationEnabled) { - setTimeout(() => { - changeView('SIGNIN'); - }, 1000); - this.setState({ - successfulSignup: true - }); - } - return (
@@ -50,7 +42,7 @@ class SignUpContent extends React.Component {
{auth.error && {auth.error}} - {beforeSignup && + {!auth.successSignUp &&
} - {successfulSignup && + {auth.successSignUp &&
{emailVerificationEnabled &&