I am using the ant-design date picker component with dayjs as the date library.
The component is controlled with the initial value being null
and the value changes to dayjs object based on some operations in the code.
The below code is a part of the implementation.
function Demo() {
const [now, setNow] = useState<any>(null);
return (
<div>
<p>{JSON.stringify(now)}</p>
<button onClick={() => setNow(dayjs())}>Update Time</button>
</div>
);
}
Currently, I am using any
as the type for now which has to be replaced by a valid type.
I tried the type to be null | typeof dayjs()
But this didn't work.