I am facing issues on changing value of date in an MUI date picker:
value.isBefore is not a function
My code:
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MobileDatePicker
className="text-[14px] !text-white"
format="DD/MM/YYYY"
defaultValue={dayjs('2023-01-19')}
value={event.date}
onChange={(v) => handleDateTime("date",dayjs(v?.$d).format('YYYY-MM-DD'))}
inputFormat="dd-MM-yyyy"
sx={{
fontSize: "0px",
padding: "0px",
"& .css-1t8l2tu-MuiInputBase-input-MuiOutlinedInput-input":
{
padding: "0px!important",
color: "white",
},
"& .MuiOutlinedInput-notchedOutline": {
border: "0px!important",
},
}}
/>
</LocalizationProvider>
handleDateTime function
const handleDateTime = (key,v) =>{
setEvent((prevEvent) => ({
...prevEvent,
[key]: v,
}));
}
and in the useState hook
const [event, setEvent] = useState({
title: null,
type: null,
date: null,
start: null,
end: null,
start_time:null,
end_time:null,
});
