Skip to content

Instantly share code, notes, and snippets.

@aabccd021
Last active May 12, 2020 01:50
Show Gist options
  • Save aabccd021/1fca3834123d189db56489be471965fd to your computer and use it in GitHub Desktop.
Save aabccd021/1fca3834123d189db56489be471965fd to your computer and use it in GitHub Desktop.
const initialState = {
password: '',
confirmPassword: ''
};
const ResetPasswordPage = () => {
const [form, setForm] = useState(initialState);
const [errorMessage, setErrorMessage] = useState(initialState);
const onFormChange = (fieldName, value) => {
const newForm = { ...form };
newForm[fieldName] = value;
newErrorMessage = getNewErrorMessage(newForm);
setForm(newForm);
setErrorMessage(newErrorMessage);
};
return (
<>
<TextField
onChange={evt => onFormChange('password', evt.target.value)}
value={form.password}
errorText={errorMessage.password || ''}
/>
<TextField
onChange={evt => onFormChange('confirmPassword', evt.target.value)}
value={form.confirmPassword}
errorText={errorMessage.confirmPassword || ''}
/>
</>
);
};
export default ResetPasswordPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment