timezone-list-hook
v1.0.1
Published
Usable, dynamic timezone list that exports a useTimezoneSelect hook
Downloads
24
Maintainers
Readme
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
andallTimezones
🪝 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!