Commit db1ee2e1 authored by Felipe's avatar Felipe Committed by Tim Neutkens

Add Intl API polyfill in with-react-intl example (#2283)

* Add Intl API polyfill in with-react-intl example

* fix linting
parent 6303d19a
...@@ -5,19 +5,24 @@ import Document, {Head, Main, NextScript} from 'next/document' ...@@ -5,19 +5,24 @@ import Document, {Head, Main, NextScript} from 'next/document'
export default class IntlDocument extends Document { export default class IntlDocument extends Document {
static async getInitialProps (context) { static async getInitialProps (context) {
const props = await super.getInitialProps(context) const props = await super.getInitialProps(context)
const {req: {localeDataScript}} = context const {req: {locale, localeDataScript}} = context
return { return {
...props, ...props,
locale,
localeDataScript localeDataScript
} }
} }
render () { render () {
// Polyfill Intl API for older browsers
const polyfill = `https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.${this.props.locale}`
return ( return (
<html> <html>
<Head /> <Head />
<body> <body>
<Main /> <Main />
<script src={polyfill} />
<script <script
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: this.props.localeDataScript __html: this.props.localeDataScript
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment