I am using jalali-react-datepicker and I want to add handleChange and onChange, I wrote my code and logic but it doesn't work:
import React, { useContext, useState } from "react";
import { DatePicker } from "jalali-react-datepicker";
import { Label } from "./../../globalStyle";
import moment from "jalali-moment";
const DatePick = ({ question, handleChange }) => {
const [date, setDate] = useState(moment().locale("fa").format("YYYY/MM/DD"));
question.answer = date;
return (
<div>
<Label>{question.text}</Label>
<DatePicker
value={date}
selected={date}
onChange={(date) => setDate(date)}
/>
</div>
);
};
export default DatePick
And I can't take the new value of datepicker and I don't know how to fix it.