InterviewHubPRO
Section Overview
Q221

Question 221 of 445

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

50%
React & Modern Frontend (445 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

What is formik?

Formik is a small react form library that helps you with the three major problems,

  1. Getting values in and out of form state
  2. Validation and error messages
  3. Handling form submission

Practical Code Example

jsx
// Formik: Form state management library
import { Formik, Form, Field } from 'formik';

function LoginForm() {
  return (
    <Formik initialValues={{ email: '' }} onSubmit={values => console.log(values)}>
      <Form>
        <Field name="email" type="email" />
        <button type="submit">Login</button>
      </Form>
    </Formik>
  );
}