Last active
May 12, 2020 01:50
-
-
Save aabccd021/1fca3834123d189db56489be471965fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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