Skip to content

Add React Hooks #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
macabeus opened this issue Apr 5, 2020 · 1 comment
Closed

Add React Hooks #467

macabeus opened this issue Apr 5, 2020 · 1 comment

Comments

@macabeus
Copy link
Contributor

macabeus commented Apr 5, 2020

fluent-react provides a simpler way to use fluent on a React application, but it's laking a built-in function to get messages using react hooks.
Currently is possible to get the messages just using a HOC using withLocalization or with <Localized />.

It's a similar approach that react-i18next already do.

Sometimes is better just to call a function instead of increasing the JSX code wrapping each message with the <Localized /> component. For example, here:

<Localized id="nav-campaigns">
  <span></span>
</Localized>

<!-- would be just... -->
<span>{t('nav-campaigns')}</span>

Related: #182

@macabeus macabeus changed the title Use React Hooks Add React Hooks Apr 5, 2020
@macabeus macabeus closed this as completed Jul 5, 2020
@stasm
Copy link
Contributor

stasm commented Jul 6, 2020

Thanks for your work on this, @macabeus! I released @fluent/react 0.13 last week with your changes: https://github.com/projectfluent/fluent.js/blob/master/fluent-react/CHANGELOG.md#fluentreact-0130-july-2-2020. I also added a note about useLocalization on the wiki: https://github.com/projectfluent/fluent.js/wiki/useLocalization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants