From e4cf66f0e4dc0882efdc99bd6517920d41d9b87a Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 21 May 2021 13:09:24 +0100 Subject: [PATCH] Move state init to constructors --- .../auth/InteractiveAuthEntryComponents.tsx | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.tsx b/src/components/views/auth/InteractiveAuthEntryComponents.tsx index a61faeea07..06263a026f 100644 --- a/src/components/views/auth/InteractiveAuthEntryComponents.tsx +++ b/src/components/views/auth/InteractiveAuthEntryComponents.tsx @@ -113,18 +113,26 @@ interface IAuthEntryProps { onPhaseChange: (phase: number) => void; } +interface IPasswordAuthEntryState { + password: string; +} + @replaceableComponent("views.auth.PasswordAuthEntry") -export class PasswordAuthEntry extends React.Component { +export class PasswordAuthEntry extends React.Component { static LOGIN_TYPE = AuthType.Password; + constructor(props) { + super(props); + + this.state = { + password: "", + }; + } + componentDidMount() { this.props.onPhaseChange(DEFAULT_PHASE); } - state = { - password: "", - }; - private onSubmit = (e: FormEvent) => { e.preventDefault(); if (this.props.busy) return; @@ -483,19 +491,29 @@ interface IMsisdnAuthEntryProps extends IAuthEntryProps { fail: (error: Error) => void; } +interface IMsisdnAuthEntryState { + token: string; + requestingToken: boolean; + errorText: string; +} + @replaceableComponent("views.auth.MsisdnAuthEntry") -export class MsisdnAuthEntry extends React.Component { +export class MsisdnAuthEntry extends React.Component { static LOGIN_TYPE = AuthType.Msisdn; private submitUrl: string; private sid: string; private msisdn: string; - state = { - token: '', - requestingToken: false, - errorText: '', - }; + constructor(props) { + super(props); + + this.state = { + token: '', + requestingToken: false, + errorText: '', + }; + } componentDidMount() { this.props.onPhaseChange(DEFAULT_PHASE);