react-timezone-select is a React component and hook designed to provide a usable and dynamic timezone selection interface. It uniquely addresses common challenges by automatically adjusting displayed choices for Daylight Savings Time (DST) and presenting a concise list of options through intelligent deduplication. The package is currently at version 3.3.3, indicating active development with frequent patch and minor updates. A key differentiator is its flexibility: developers can either use the pre-built `TimezoneSelect` component, which integrates with `react-select`, or leverage the `useTimezoneSelect` hook to integrate timezone selection logic with their own custom select components. It ships with comprehensive TypeScript types, ensuring a robust developer experience.
npm install react-timezone-selectVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate the `TimezoneSelect` component into a React application, manage its selected value using React state, and display the resulting timezone object.
Migrate your project to use ES Modules `import` syntax. If using Node.js, ensure your package.json specifies `"type": "module"` or use `.mjs` file extensions. For bundlers, verify your configuration supports ESM.
Remove the `maxAbbrLength` prop from your `TimezoneSelect` component usage. The component now handles abbreviation lengths internally.
Install `react-select` via npm or yarn: `npm install react-select` or `yarn add react-select`. If you wish to avoid this dependency, use the `useTimezoneSelect` hook with a custom select component.
Ensure `"use client";` is present at the top of the file where `TimezoneSelect` is used, or in a parent component that orchestrates client-side interactions.
Update to version 3.2.7 or newer. If upgrading is not possible, ensure that the `value` prop is always a valid `string | ITimezone` and never `null`.
Switch to ES Module `import` syntax: `import TimezoneSelect from 'react-timezone-select';`. Ensure your environment (Node.js, bundler) is configured for ESM.
Verify `react-select` is installed (`npm install react-select`) and that its version (`^5.9.0`) is compatible with `react-timezone-select`. Check for other `react-select` related warnings in the console.
Remove the `maxAbbrLength` prop from your `TimezoneSelect` component usage. This prop is no longer supported.
Use a default import: `import TimezoneSelect from 'react-timezone-select';`.