How to use the piral.useDynamicLanguage function in piral

To help you get started, we’ve selected a few piral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smapiot / piral / src / samples / sample-piral / src / components / LanguagePicker.tsx View on Github external
const LanguagePickerView: React.FC = ({ selected, available }) => {
  const [open, setOpen] = React.useState(false);
  const [language, setLanguage] = useDynamicLanguage(selected, loadLanguage);
  const container = React.useRef();
  const translate = useTranslate();
  useOnClickOutside(container, () => setOpen(false));

  return (
    <div>
      <div> setOpen(!open)}&gt;
        
      </div>
      <ul>
        {available.map(lang =&gt; (
          <li> setLanguage(lang)}&gt;
             <span>{translate(lang)}</span>
          </li>
        ))}
      </ul></div>

piral

The all-in-one piral package.

MIT
Latest version published 6 days ago

Package Health Score

84 / 100
Full package analysis