'React Datepicker default value showing on the form, but still yup showing value required

This is the react datepicker:

<Controller
    control={control}
    name="release_date"
    render={({
        field: { onChange, onBlur, value, ref },
    }) => (
        <ReactDatePicker
            onChange={onChange}
            onBlur={onBlur}
            selected={value}
            className="form-control w-full"
            dateFormat="MMM dd, yyyy"
            selected={
                item.release_date
                    ? new Date(item.release_date)
                    : null
            }
            defaultValue={
                item.release_date
                    ? new Date(item.release_date)
                    : null
            }
        />
    )}
/>

With this code, on edit page, on react field it is showing the date correctly but still the Yup validation showing value required error.

This is my Yup code.

const schema = Yup.object({

    release_date: Yup.date().when("to_be_announced", {
        is: false,
        then: Yup.date().required("Release date is required"),
    }),

});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source