Open n-glaz opened 1 year ago
According to the README, you have to import the corresponding locales from date-fns
.
import { useState } from "react";
import { createRoot } from "react-dom/client";
import DatePicker, { registerLocale } from "react-datepicker";
import es from 'date-fns/locale/en-US';
registerLocale('en-US', es)
import "react-datepicker/dist/react-datepicker.css";
// CSS Modules, react-datepicker-cssmodules.css
// import 'react-datepicker/dist/react-datepicker-cssmodules.css';
const Example = (): JSX.Element => {
const [startDate, setStartDate] = useState(new Date());
return (
<DatePicker
locale="en-US"
selected={startDate}
onChange={(date) => date && setStartDate(date)}
/>
);
};
const container = document.querySelector("#app")!;
const root = createRoot(container);
root.render(<Example />);
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.
Describe the bug Setting
ReactDatePicker
'slocale
attribute to 'en-US' or "en-US" causes 395 warnings to be thrown in the console when the datepicker is interacted with.Dates still appear to be displayed properly as per the locale.
To Reproduce
Expected behavior
I expect to not get 395 console errors when setting the locale attribute to 'en-US'.
Screenshots
Desktop (please complete the following information):
"react-datepicker": "^4.8.0"