GeethikaG
Reactiflux3y ago
1 reply
Geethika

React-hook-form displaying required type error even when fields are populated.

Hi! I am using react-hook-form in my React.js project. I have fields that use controller as they are custom components. When I fill in those fields and submit I am getting the error message fields are required.

Below is the code for components:

 <Controller
                                        control={control}
                                        name="status"
                                        rules={{ required: true }}
                                        render={({ field: { onChange, value } }) => (
                                            <FormRowSelect
                                                name="status"
                                                labelText="FreeLance Availability"
                                                value={value}
                                                handleChange={onChange}
                                                list={["Yes", "No"]}
                                                disabled={!isEditing}
                                            />
                                        )}
                                    />
                                    {errors.status &&
                                        <Notification color="red" title="Please fill!">
                                            Status is mandatory!
                                        </Notification>

                                    }

Please help!
Was this page helpful?