Skip to content
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

Storybook Integration #34

Closed
dsauna opened this issue Jun 7, 2021 · 1 comment
Closed

Storybook Integration #34

dsauna opened this issue Jun 7, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@dsauna
Copy link

dsauna commented Jun 7, 2021

Storybook is very useful for testing components in isolation, most of said components use the useTranslation hook and Storybook doesn't recognize it

A Storyook addon similar to the one used by react-intl would be useful https://storybook.js.org/addons/storybook-addon-intl/

One alternative is passing the hook from the parent to the child that way the child is unaware of the hook and props can be used.

@amannn
Copy link
Owner

amannn commented Jan 4, 2022

I didn't try this out myself yet, but generally this should be possible if you add a global decorator which configures the NextIntlProvider with an explicit locale and messages.

I've added a small fix in #76 that should help with this use case, so if you're on a previous version and would like to integrate with Storybook, please upgrade!

There's now also a section in the FAQ now that covers Storybook and Jest integration.

If there is something missing or this library could make it easier to integrate with Storybook, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants