Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
94e81c02
Commit
94e81c02
authored
Oct 26, 2019
by
LadiesMan217
Committed by
Tim Neutkens
Oct 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update with-react-intl example (#9180)
parent
2fcff3de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
_app.js
examples/with-react-intl/pages/_app.js
+16
-4
No files found.
examples/with-react-intl/pages/_app.js
View file @
94e81c02
import
App
from
'next/app'
import
App
from
'next/app'
import
React
from
'react'
import
React
from
'react'
import
{
IntlProvider
}
from
'react-intl'
import
{
createIntl
,
createIntlCache
,
RawIntlProvider
}
from
'react-intl'
// This is optional but highly recommended
// since it prevents memory leak
const
cache
=
createIntlCache
()
export
default
class
MyApp
extends
App
{
export
default
class
MyApp
extends
App
{
static
async
getInitialProps
({
Component
,
router
,
ctx
})
{
static
async
getInitialProps
({
Component
,
ctx
})
{
let
pageProps
=
{}
let
pageProps
=
{}
if
(
Component
.
getInitialProps
)
{
if
(
Component
.
getInitialProps
)
{
...
@@ -21,10 +25,18 @@ export default class MyApp extends App {
...
@@ -21,10 +25,18 @@ export default class MyApp extends App {
render
()
{
render
()
{
const
{
Component
,
pageProps
,
locale
,
messages
}
=
this
.
props
const
{
Component
,
pageProps
,
locale
,
messages
}
=
this
.
props
const
intl
=
createIntl
(
{
locale
,
messages
},
cache
)
return
(
return
(
<
IntlProvider
locale
=
{
locale
}
messages
=
{
messages
}
>
<
RawIntlProvider
value
=
{
intl
}
>
<
Component
{...
pageProps
}
/
>
<
Component
{...
pageProps
}
/
>
<
/IntlProvider
>
<
/
Raw
IntlProvider
>
)
)
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment