react-datetime-picker is a React component that provides a flexible and comprehensive solution for picking both dates and times. It is currently at stable version 7.0.2 and actively maintained, with frequent minor and patch releases, and major versions introducing modern practices like ESM-only builds. Key differentiators include its focus on integrating seamlessly into React applications, shipping with TypeScript types for improved developer experience, and embracing modern web standards and security features such as OIDC trusted publishing and npm provenance. The component supports a wide range of React versions, from 16.8.0 up to 19.0.0, and simplifies date and time input within forms.
npm install react-datetime-pickerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate DateTimePicker into a React functional component using useState for managing the selected date and time. It also includes necessary CSS imports and common prop configurations for formatting, icons, and locale.
For applications, ensure your bundler supports ESM. For testing with Jest, consider migrating to Vitest or configuring Jest for ESM support (experimental at the time of v7 release).
Enable the New JSX Transform in your Babel configuration or build setup as per the React documentation (e.g., set `"runtime": "automatic"` in `@babel/preset-react`).
Migrate from `propTypes` to TypeScript for static type checking or adopt a runtime type-checking solution like `zod` or `io-ts` if dynamic validation is strictly necessary.
Consider migrating your testing framework to Vitest, which has robust ESM support, or carefully configure Jest for ESM (which may require experimental flags or specific transformers).
No direct fix needed; this is an improvement. Ensure your build pipeline and security scanners are up-to-date to benefit from and correctly interpret these security enhancements.
Upgrade to react-datetime-picker v7.0.2 or newer, as this specific bug was fixed in that release.
Upgrade to react-datetime-picker v5.5.2 or newer, where this server-side rendering specific prop type validation error was addressed.
Upgrade to react-datetime-picker v5.5.0 or newer. This version specifically addressed `HTMLElement is not defined` errors during SSR by ensuring DOM-specific code is not executed on the server.
Configure Jest to transpile ESM modules or consider migrating to a test runner like Vitest that natively supports ESM. This might involve using `jest-esm-transformer` or updating your `package.json` to include `"type": "module"` and configuring Jest accordingly.