react-countdown is a highly customizable React component designed to display countdowns. It is currently stable at version 2.3.6 and has seen active maintenance, with multiple bugfix and minor feature releases within the 2.x series. The library allows developers to define a target date and provides flexible rendering options, including a custom `renderer` function or rendering a child component upon completion. Key features include support for displaying milliseconds with configurable precision, an `overtime` prop to allow negative countdowns, and an API to programmatically `stop`, `isStarted`, and `isStopped` the countdown. It ships with TypeScript types, ensuring type safety for React applications. This package differentiates itself through its extensive customization capabilities and robust API for managing countdown state.
npm install react-countdownVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic countdown with a custom renderer and completion callback, using modern React 18+ ReactDOM.createRoot.
Always provide the `date` prop to the `Countdown` component. TypeScript users will encounter a compilation error if omitted.
To show milliseconds, set `intervalDelay` to a value less than 1000ms (e.g., `0` or `10`) and `precision` to `1`, `2`, or `3`.
Upgrade to version `2.3.3` or newer, which includes a fix to ensure `onComplete` triggers consistently, even if the countdown is completed on start.
This was an internal fix. Users should ensure their project's React and TypeScript versions are up-to-date and compatible, though this change should not directly impact consumer code unless custom type overrides were in place.
Ensure the `date` prop is always provided, e.g., `<Countdown date={Date.now() + 10000} />`.Add `intervalDelay={0}` (or a small number like `10`) and `precision={3}` (for 3 decimal places of milliseconds) to the `Countdown` component props.Change the import statement from `import { Countdown } from 'react-countdown';` to `import Countdown from 'react-countdown';`.