Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Migrate string refs of currentPassword and password refs
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhar02 committed Nov 12, 2020
1 parent d6a1d8d commit 0a75f3a
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Props = {
}

export default class ResetPasswordModal extends React.PureComponent<Props, State> {
private currentPasswordRef: React.RefObject<HTMLInputElement>;
private passwordRef: React.RefObject<HTMLInputElement>;
public static defaultProps: Partial<Props> = {
show: false,
};
Expand All @@ -47,6 +49,9 @@ export default class ResetPasswordModal extends React.PureComponent<Props, State
serverErrorNewPass: null,
serverErrorCurrentPass: null,
};

this.currentPasswordRef = React.createRef();
this.passwordRef = React.createRef();
}

public componentWillUnmount(): void {
Expand All @@ -63,8 +68,8 @@ export default class ResetPasswordModal extends React.PureComponent<Props, State
}

let currentPassword = '';
if (this.refs.currentPassword) {
currentPassword = (this.refs.currentPassword as HTMLInputElement).value;
if (this.currentPasswordRef.current) {
currentPassword = (this.currentPasswordRef.current as HTMLInputElement).value;
if (currentPassword === '') {
const errorMsg = (
<FormattedMessage
Expand All @@ -77,7 +82,7 @@ export default class ResetPasswordModal extends React.PureComponent<Props, State
}
}

const password = (this.refs.password as HTMLInputElement).value;
const password = (this.passwordRef.current as HTMLInputElement).value;

const {valid, error} = Utils.isValidPassword(password, this.props.passwordConfig);
if (!valid && error) {
Expand Down Expand Up @@ -159,7 +164,7 @@ export default class ResetPasswordModal extends React.PureComponent<Props, State
</span>
<input
type='password'
ref='currentPassword'
ref={this.currentPasswordRef}
className='form-control'
autoFocus={true}
/>
Expand Down Expand Up @@ -205,7 +210,7 @@ export default class ResetPasswordModal extends React.PureComponent<Props, State
</span>
<input
type='password'
ref='password'
ref={this.passwordRef}
className='form-control'
autoFocus={newPasswordFocus}
/>
Expand Down

0 comments on commit 0a75f3a

Please sign in to comment.