-
Notifications
You must be signed in to change notification settings - Fork 178
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
How to use with Storybook? #175
Comments
Hi @jdahdah I got the file: import React from 'react';
import { IntlProvider, IntlContextProvider} from 'gatsby-plugin-intl';
import messages from '../src/intl/en.json';
import { createIntl, createIntlCache } from 'react-intl';
const intlCache = createIntlCache();
const intl = createIntl(
{
defaultLanguage: 'en',
language: 'en',
messages: messages,
},
intlCache,
);
export default function WrapWithProvider(Story) {
return (
<IntlProvider
locale={intl.language}
defaultLocale={intl.defaultLanguage}
messages={intl.messages}
>
<IntlContextProvider
value={intl}
>
<Story />
</IntlContextProvider>
</IntlProvider>
);
} File: import WrapWithProvider from './wrap-with-provider';
export const decorators = [
WrapWithProvider,
]; |
@jdahdah More or less, the |
@bud-mo Amazing, I will give this a shot next week and let you know how it goes. Thank you for sharing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does anyone by chance have a working example of how to use this with Storybook? Some of my components use
<FormattedMessage />
and<Link />
fromgatsby-plugin-intl
, and I'm not sure how to get those working within the Storybook context.I tried adding context providers like
<IntlProvider />
and<IntlContextProvider />
to a story, but they rely onpageContext
, which is not available outside of thegatsby
runtime environment.The text was updated successfully, but these errors were encountered: