react-date-picker is a flexible date picker component for React applications, providing robust functionalities for selecting dates, months, and years. Its current stable version is 12.0.2. The package maintains an active release cadence, with minor and patch updates occurring frequently to address bugs and improve developer experience, while major versions are released less often, coinciding with significant architectural shifts or React version compatibility updates. Key differentiators include its lightweight nature, comprehensive TypeScript support, enhanced prop documentation via JSDoc for improved IDE assistance, and its transition to being an ESM-only package since v12.0.0, aligning with modern JavaScript module standards. It supports React versions 16.8.0 through 19.0.0 and mandates the New JSX Transform since v11.0.0.
npm install react-date-pickerVerified import paths — ran on the pinned version, not inferred.
This quickstart code demonstrates how to integrate `react-date-picker` into a React component, manage its state using `useState`, handle date changes, and correctly import required styles.
Migrate all imports from CommonJS 'require()' to ES Modules 'import' syntax. Ensure your build configuration (e.g., Webpack, Rollup, Parcel) is set up to correctly handle ESM.
Ensure your project's build setup (e.g., Babel with '@babel/preset-react') is configured to use the New JSX Transform. Refer to the official React documentation for migration instructions.
If your project relies on `propTypes` for type checking, consider migrating to TypeScript or implementing an alternative runtime type-checking solution.
Consider migrating your unit testing framework to Vitest, which has native ESM support, or configure Jest to correctly handle ESM modules by using transformers like `babel-jest` with appropriate module configurations.
Update `react-date-picker` to version `12.0.2` or newer to resolve this bug fix.
Change your import statements from `const DatePicker = require('react-date-picker');` to `import DatePicker from 'react-date-picker';`. Verify your bundler/environment supports ESM.Ensure the `portalContainer` prop, if used, is provided with a valid DOM element or reference. For SSR issues, update to `react-date-picker@10.5.1` or newer.
Update `react-date-picker` to version `10.5.0` or newer, which includes fixes for this specific SSR compatibility issue.