The <Formik> Component and Render Props
You'll learn Formik's original component-based API that uses render props to give you complete control over form layout while still managing state and validation.
The Component-Based Alternative
While useFormik() is a hook-based approach, Formik originally shipped with a <Formik> component that uses the render props pattern you've already learned. Instead of calling a hook, you render a component and pass it a function as children (or as a render prop).
Basic Structure
import { Formik } from 'formik';
<Formik
initialValues={{ email: '', password: '' }}
onSubmit={(values) => console.log(values)}
>
{(formik) => (
<form onSubmit={formik.handleSubmit}>
<input
name="email"
value={formik.values.email}
onChange={formik.handleChange}
/>
<button type="submit">Submit</button>
</form>
)}
</Formik>
The <Formik> component takes your configuration props (initialValues, onSubmit, etc.) and calls your render function with a formik object containing all the state and helpers—the same object useFormik() returns.
Why This Pattern Existed
This was Formik's original API before hooks existed. The render prop gives you complete control over JSX layout while Formik handles state management behind the scenes. You can destructure exactly what you need from the formik object.
It's essentially inversion of control: Formik manages the state, you control the rendering.
Modern Usage
Today, most developers prefer useFormik() or Formik's specialized field components (<Field>, <Form>), but you'll encounter this pattern in older codebases. It's also useful when you need maximum JSX flexibility without creating a separate component.
Key Takeaway: The <Formik> component with render props is Formik's original API that provides state management through a render function, giving you full JSX control—a pre-hooks pattern you'll see in legacy code.