diff --git a/src/routes/Intro/Intro.js b/src/routes/Intro/Intro.js index e392f8c19..fac91c781 100644 --- a/src/routes/Intro/Intro.js +++ b/src/routes/Intro/Intro.js @@ -1,6 +1,6 @@ import React, { Component, Fragment } from 'react'; import Icon from 'stremio-icons/dom'; -import { Button, Input, Link } from 'stremio-common'; +import { Input } from 'stremio-common'; import ConsentCheckbox from './ConsentCheckbox'; import styles from './styles'; @@ -33,10 +33,30 @@ class Intro extends Component { }; } + shouldComponentUpdate(nextProps, nextState) { + return nextState.selectedForm !== this.state.selectedForm || + nextState.termsAccepted !== this.state.termsAccepted || + nextState.privacyPolicyAccepted !== this.state.privacyPolicyAccepted || + nextState.marketingAccepted !== this.state.marketingAccepted || + nextState.email !== this.state.email || + nextState.password !== this.state.password || + nextState.confirmPassword !== this.state.confirmPassword || + nextState.error !== this.state.error; + } + + componentDidUpdate(prevProps, prevState) { + if (prevState.error !== this.state.error && this.state.error.length > 0) { + this.errorRef.current.scrollIntoView(); + } + + if (prevState.selectedForm !== this.state.selectedForm) { + this.emailRef.current.focus(); + } + } + changeSelectedForm = (event) => { - event.currentTarget.blur(); this.setState({ - selectedForm: event.currentTarget.dataset.option, + selectedForm: event.currentTarget.dataset.form, termsAccepted: false, privacyPolicyAccepted: false, marketingAccepted: false, @@ -77,27 +97,6 @@ class Intro extends Component { })); } - shouldComponentUpdate(nextProps, nextState) { - return nextState.selectedForm !== this.state.selectedForm || - nextState.termsAccepted !== this.state.termsAccepted || - nextState.privacyPolicyAccepted !== this.state.privacyPolicyAccepted || - nextState.marketingAccepted !== this.state.marketingAccepted || - nextState.email !== this.state.email || - nextState.password !== this.state.password || - nextState.confirmPassword !== this.state.confirmPassword || - nextState.error !== this.state.error; - } - - componentDidUpdate(prevProps, prevState) { - if (prevState.error !== this.state.error && this.state.error.length > 0) { - this.errorRef.current.scrollIntoView(); - } - - if (prevState.selectedForm !== this.state.selectedForm) { - this.emailRef.current.focus(); - } - } - loginOnSubmit = (event) => { event.preventDefault(); if (this.state.email.length < 8) { @@ -174,17 +173,17 @@ class Intro extends Component {
- +
We won't post anything on your behalf
- + { this.state.selectedForm === FORMS.LOGIN ? - Forgot password? + Forgot password? : @@ -201,10 +200,10 @@ class Intro extends Component { } - + {this.state.selectedForm === FORMS.SIGN_UP ? 'LOG IN' : 'SING UP WITH EMAIL'} { this.state.selectedForm === FORMS.SIGN_UP ? - + GUEST LOGIN : null }