faruqhossen30
3/20/2020 - 9:47 AM

Basic Forkik 2

import React, { Component } from 'react';
import { Formik, Form, Field } from 'formik'

class MyFormik extends Component {
    render() {
        return (
            <div>
                <div className="container">
                    <div className="row">
                        <div className="col-6 offset-3 card">
                            <h4 className='card-header'>This is formik</h4>
                            <Formik
                                initialValues={{
                                    name: 'fdg',
                                    email: '',
                                    password: ''
                                }}
                                onSubmit={(values, formikBag) => {
                                    console.log(values);
                                    console.log(formikBag);



                                }}
                            >
                                {(props) => {
                                    // console.log(props)

                                    return (
                                        <Form>
                                            <Field
                                                type="text"
                                                name='name'
                                                placeholder='Enter Name'
                                            />
                                            <br/>
                                            <Field
                                                type="email"
                                                name='email'
                                                placeholder='Enter Email'
                                            />
                                            <br/>
                                            <Field
                                                type="password"
                                                name='password'
                                                placeholder='Enter Password'
                                            />
                                            <br/>
                                            <button type='submit'>Submit</button>
                                        </Form>
                                    )
                                }}
                            </Formik>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

export default MyFormik;