Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Formik and Form.Check does not capture value in react js ?

By M.K. Verma · 2 May 2022

Formik and Form.Check does not capture value in react js ?

I was able to fix it and thought to post the answer in case it helps someone else a a later stage

{['Football', 'Golf', 'Rugby', 'Tennis'].map((secondaryinterest) => (
            <div key={`${secondaryinterest}`} className="mb-3">
                <Form.Check
                    type='checkbox'
                    name='secondaryinterest'
                    value={`${secondaryinterest}`}
                    label={`${secondaryinterest}`}
                    onChange={formik.handleChange}
                />
            </div>
        ))}

I stipulated the name and value fields. Also the {...formik.getFieldProps('secondaryinterest')} was redundant.