import React, { useRef } from 'react'; import PropTypes from 'prop-types'; type LocaleOptionsProps = { locale: string | undefined; setLocale: (locale: string | undefined) => void; }; export default function LocaleOptions({ locale, setLocale }: LocaleOptionsProps) { const customLocale = useRef(null); function onChange(event: React.ChangeEvent) { const { value: nextLocale } = event.target; if (nextLocale === 'undefined') { setLocale(undefined); } else { setLocale(nextLocale); } } function onCustomChange(event: React.FormEvent) { event.preventDefault(); const input = customLocale.current; const { value: nextLocale } = input as HTMLInputElement; setLocale(nextLocale); } function resetLocale() { setLocale(undefined); } return (
Locale
   
); } LocaleOptions.propTypes = { locale: PropTypes.string, setLocale: PropTypes.func.isRequired, };