25
loading...
This website collects cookies to deliver better user experience
react-intl
, particularly the SimpleLocalize
component, relies on the page's context to derive the current language. This helps determine which text to use and which links to follow but if your page is broken down into separate components like mine then you're likely going to run into this error.SimpleLocalize
needed, which wasn't the case.{...props}
) but if you're committed to fine-tuning for performance feel free to destructure what you need.const IndexPage = (props) => {
return (
<Layout>
...
<AppLinks {...props} />
...
</Layout>
)
}
const AppLinks = (props) => {
return (
<SimpleLocalize {...props}>
...
<FormattedMessage
id="app-links-header"
/>
...
<FormattedMessage
id="app-links-subheader"
/>
...
</SimpleLocalize>
)
}
- index.js
-- Intro.js
--- EarlyAccessForm.js
Intro.js
:<EarlyAccessForm {...props.pageContext} />
EarlyAccessForm.js
:...
render() {
return (
<SimpleLocalize {...this.props}>
...
{...this.props}
since EarlyAccessForm
is a class-based component but to use it in a functional component just change {...this.props)
to {...props}
.react-intl
before and have any suggestions, feel free to drop them down in the comments!