You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Move state init to constructors
This commit is contained in:
		@@ -113,18 +113,26 @@ interface IAuthEntryProps {
 | 
				
			|||||||
    onPhaseChange: (phase: number) => void;
 | 
					    onPhaseChange: (phase: number) => void;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface IPasswordAuthEntryState {
 | 
				
			||||||
 | 
					    password: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@replaceableComponent("views.auth.PasswordAuthEntry")
 | 
					@replaceableComponent("views.auth.PasswordAuthEntry")
 | 
				
			||||||
export class PasswordAuthEntry extends React.Component<IAuthEntryProps> {
 | 
					export class PasswordAuthEntry extends React.Component<IAuthEntryProps, IPasswordAuthEntryState> {
 | 
				
			||||||
    static LOGIN_TYPE = AuthType.Password;
 | 
					    static LOGIN_TYPE = AuthType.Password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    constructor(props) {
 | 
				
			||||||
 | 
					        super(props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.state = {
 | 
				
			||||||
 | 
					            password: "",
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    componentDidMount() {
 | 
					    componentDidMount() {
 | 
				
			||||||
        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
					        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state = {
 | 
					 | 
				
			||||||
        password: "",
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private onSubmit = (e: FormEvent) => {
 | 
					    private onSubmit = (e: FormEvent) => {
 | 
				
			||||||
        e.preventDefault();
 | 
					        e.preventDefault();
 | 
				
			||||||
        if (this.props.busy) return;
 | 
					        if (this.props.busy) return;
 | 
				
			||||||
@@ -483,19 +491,29 @@ interface IMsisdnAuthEntryProps extends IAuthEntryProps {
 | 
				
			|||||||
    fail: (error: Error) => void;
 | 
					    fail: (error: Error) => void;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface IMsisdnAuthEntryState {
 | 
				
			||||||
 | 
					    token: string;
 | 
				
			||||||
 | 
					    requestingToken: boolean;
 | 
				
			||||||
 | 
					    errorText: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@replaceableComponent("views.auth.MsisdnAuthEntry")
 | 
					@replaceableComponent("views.auth.MsisdnAuthEntry")
 | 
				
			||||||
export class MsisdnAuthEntry extends React.Component<IMsisdnAuthEntryProps> {
 | 
					export class MsisdnAuthEntry extends React.Component<IMsisdnAuthEntryProps, IMsisdnAuthEntryState> {
 | 
				
			||||||
    static LOGIN_TYPE = AuthType.Msisdn;
 | 
					    static LOGIN_TYPE = AuthType.Msisdn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private submitUrl: string;
 | 
					    private submitUrl: string;
 | 
				
			||||||
    private sid: string;
 | 
					    private sid: string;
 | 
				
			||||||
    private msisdn: string;
 | 
					    private msisdn: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state = {
 | 
					    constructor(props) {
 | 
				
			||||||
        token: '',
 | 
					        super(props);
 | 
				
			||||||
        requestingToken: false,
 | 
					
 | 
				
			||||||
        errorText: '',
 | 
					        this.state = {
 | 
				
			||||||
    };
 | 
					            token: '',
 | 
				
			||||||
 | 
					            requestingToken: false,
 | 
				
			||||||
 | 
					            errorText: '',
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    componentDidMount() {
 | 
					    componentDidMount() {
 | 
				
			||||||
        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
					        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user