Grokking React Native
0% completed
Validating User Input Using Third-Party Libraries
Three fields needed four state variables and three validation if statements in the previous lesson, and each new field adds to both. Writing rules by hand is fine for one or two fields. As a form grows, the same patterns repeat, and libraries can take over that repetition: Yup describes the rules, and Formik manages the form.
Both are plain JavaScript packages with no native code, so you install them with npm:
npm install yup formik
Describing Rules with Yup
A schema is an object that lists the rules for your data in one place, and Yup is a library for writing schemas
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%