Last active
November 13, 2019 17:38
-
-
Save ptrin/9d8d9970a7db5cdb1ea35de40310264c to your computer and use it in GitHub Desktop.
Formik a11y examples
This file contains hidden or 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
<ErrorMessage name="firstName"> | |
{msg => ( | |
<div id="firstName-error" className="invalid-feedback"> | |
{msg} | |
</div> | |
)} | |
</ErrorMessage> |
This file contains hidden or 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
<Field | |
className={classNames("form-control", { | |
"is-invalid": errors.firstName && touched.firstName | |
})} | |
aria-invalid={errors.firstName && touched.firstName ? 'true' : null} | |
aria-describedby={errors.firstName && touched.firstName ? 'firstName-error' : null} | |
aria-required="true" | |
name="firstName" | |
id="firstName" | |
/> |
This file contains hidden or 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
innerRef={ (input) => { this.firstNameInput = input }} |
This file contains hidden or 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
componentDidMount() { | |
this.firstNameInput.focus(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment