timezone-list-hook
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

timezone-list-hook

This is a fork of ndom91/react-timezone-select with the following changes:

  • [x] Removed react-select dependency
  • [x] Exported only useTimezoneSelect and allTimezones

🪝 Hooks

import { useTimezoneSelect, allTimezones } from 'timezone-list-hook'

const labelStyle = 'original'
const timezones = {
  ...allTimezones,
  'Europe/Berlin': 'Frankfurt',
}

const customSelect = () => {
  const { options, parseTimezone } = useTimezoneSelect({
    labelStyle,
    timezones,
  })

  return (
    <select onChange={(e) => onChange(parseTimezone(e.currentTarget.value))}>
      {options.map((option) => (
        <option value={option.value}>{option.label}</option>
      ))}
    </select>
  )
}

OR

You can use the useTimezoneSelect hook to build your own custom timezone select component.

🚧 Contributing

Pull requests are always welcome! Please stick to repo settings (prettier, eslint, etc.), and if adding new features, please consider adding test(s) and documentation where appropriate!

Package Sidebar

Install

npm i timezone-list-hook

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

12.7 kB

Total Files

5

Last publish

Collaborators

  • codellyson