I'm trying to create a custom datepicker following the instructions in documentation and after a long time I was able to do, but I'm still receiveing an error that says "Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?" I'm using typescript in my project.
import DatePicker from "react-datepicker";
import React, { useContext, useState } from "react";
import "react-datepicker/dist/react-datepicker.css";
const Feed: React.FC = () => {
const [startDate, setStartDate] = useState();
const ExampleCustomInput = ({
value,
onClick,
}: {
value?: any;
onClick?: any;
}) => (
<DateFilter className="example-custom-input" onClick={onClick}>
{value || "Escolha uma data"}
<CalendarIcon />
</DateFilter>
);
return (
<Container>
<LeftContent>
<NewPost onClick={openModal}>+ Novo post</NewPost>
<DatePicker
dateFormat="dd/MM/yyyy"
selected={startDate}
onChange={(date: any) => setStartDate(date)}
customInput={<ExampleCustomInput />}
/>
</LeftContent>
</Container>
);
};
export default Feed;