sergioramos / formik-observer

BSD 3-Clause "New" or "Revised" License
21 stars 1 forks source link

formik-observer

npm License: BSD 3-clause "New" or "Revised" License standard-readme compliant

David David David

Table of Contents

Install

yarn add formik-observer
npm install formik-observer

Usage

import React from 'react';
import { Formik, Field, Form } from 'formik';
import FormikObserver from 'formik-observer';

export const Signup = () => (
  <div>
    <h1>My Cool Persisted Form</h1>
    <Formik
      onSubmit={values => console.log(values)}
      initialValues={{ firstName: '', lastName: '', email: '' }}
    >
      {props => (
        <Form className="whatever">
          <Field name="firstName" placeholder="First Name" />
          <Field name="lastName" placeholder="Last Name" />
          <Field name="email" type="email" placeholder="Email Address" />
          <button type="submit">Submit</button>
          <FormikObserver
            onChange={({ values }) => console.log('onchange', values)}
          />
        </Form>
      )}
    </Formik>
  </div>
);

License

BSD-3-Clause