React-clock is a specialized React component library offering an analog clock display for web applications. It provides a highly configurable clock, allowing developers to set the current time, specify display precision down to milliseconds, and customize the appearance of hour marks and numbers. The library is currently stable at version 6.0.0 and actively maintained, with regular updates addressing bug fixes, performance enhancements, and compatibility with the latest React versions, including React 19. It ships with full TypeScript support, exporting its component props for robust type-checking. A key differentiator is its focus purely on an analog clock interface, providing a lightweight, purpose-built solution without the overhead of digital or calendar functionalities, offering a simple and elegant way to integrate time visualization into React applications. As of v6.0.0, it is an ESM-only package.
npm install react-clockVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to render a basic analog clock that updates every second using React hooks.
Migrate your project to use ESM `import` statements and ensure your build tools (like Webpack, Rollup, or Vite) are configured for ESM. For Jest users, consider migrating to Vitest or configuring Jest to handle ESM, as it may cause issues with unit tests.
Enable the new JSX transform in your Babel or TypeScript configuration. Refer to the official React blog post on the new JSX transform for detailed instructions.
Migrate from `propTypes` to TypeScript or another static type-checking solution. The package itself ships with TypeScript types, which are recommended for use.
Manually install `@types/react` and `@types/react-dom` if you are using TypeScript and they are not automatically resolved by your package manager or already present as direct dependencies.
Pass a consistent `locale` prop to the `Clock` component during both server and client rendering, e.g., `<Clock value={value} locale="en-US" />`.Change `const Clock = require('react-clock');` to `import Clock from 'react-clock';`Update your Babel or TypeScript configuration to enable React's new JSX transform. For Babel, ensure `@babel/preset-react` is configured with `runtime: 'automatic'`.
Remove any usage of `propTypes` with `react-clock`. For type checking, rely on TypeScript or another external validation library.