1.0.1 • Published 4 months ago

timezone-list-hook v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

timezone-list-hook

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

  • Removed react-select dependency
  • 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!

1.0.1

4 months ago

1.0.0

4 months ago