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
beed775e
Commit
beed775e
authored
Oct 16, 2019
by
Gerald Monaco
Committed by
Tim Neutkens
Oct 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update legacy _app context (#9083)
parent
b6be95ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
25 deletions
+7
-25
router.ts
packages/next/client/router.ts
+1
-1
with-router.tsx
packages/next/client/with-router.tsx
+4
-12
_app.tsx
packages/next/pages/_app.tsx
+1
-11
index.test.js
test/integration/build-stats-output/test/index.test.js
+1
-1
No files found.
packages/next/client/router.ts
View file @
beed775e
...
@@ -13,7 +13,7 @@ type SingletonRouterBase = {
...
@@ -13,7 +13,7 @@ type SingletonRouterBase = {
ready
(
cb
:
()
=>
any
):
void
ready
(
cb
:
()
=>
any
):
void
}
}
export
{
Router
,
NextRouter
}
export
{
Router
,
RouterContext
,
NextRouter
}
export
type
SingletonRouter
=
SingletonRouterBase
&
NextRouter
export
type
SingletonRouter
=
SingletonRouterBase
&
NextRouter
...
...
packages/next/client/with-router.tsx
View file @
beed775e
import
React
from
'react'
import
React
from
'react'
import
PropTypes
from
'prop-types'
import
{
NextComponentType
,
NextPageContext
}
from
'../next-server/lib/utils'
import
{
NextComponentType
,
NextPageContext
}
from
'../next-server/lib/utils'
import
{
NextRouter
}
from
'./router'
import
{
NextRouter
,
RouterContext
}
from
'./router'
export
type
WithRouterProps
=
{
export
type
WithRouterProps
=
{
router
:
NextRouter
router
:
NextRouter
...
@@ -21,19 +20,12 @@ export default function withRouter<
...
@@ -21,19 +20,12 @@ export default function withRouter<
class
WithRouteWrapper
extends
React
.
Component
<
ExcludeRouterProps
<
P
>>
{
class
WithRouteWrapper
extends
React
.
Component
<
ExcludeRouterProps
<
P
>>
{
static
displayName
?:
string
static
displayName
?:
string
static
getInitialProps
?:
any
static
getInitialProps
?:
any
static
contextTypes
=
{
static
contextType
=
RouterContext
router
:
PropTypes
.
object
,
}
context
!
:
WithRouterProps
context
!
:
React
.
ContextType
<
typeof
RouterContext
>
render
()
{
render
()
{
return
(
return
<
ComposedComponent
router=
{
this
.
context
}
{
...
this
.
props
as
any
}
/>
<
ComposedComponent
router=
{
this
.
context
.
router
}
{
...
this
.
props
as
any
}
/>
)
}
}
}
}
...
...
packages/next/pages/_app.tsx
View file @
beed775e
import
React
,
{
ErrorInfo
}
from
'react'
import
React
,
{
ErrorInfo
}
from
'react'
import
PropTypes
from
'prop-types'
import
{
import
{
execOnce
,
execOnce
,
loadGetInitialProps
,
loadGetInitialProps
,
...
@@ -7,7 +6,7 @@ import {
...
@@ -7,7 +6,7 @@ import {
AppInitialProps
,
AppInitialProps
,
AppPropsType
,
AppPropsType
,
}
from
'../next-server/lib/utils'
}
from
'../next-server/lib/utils'
import
{
Router
,
makePublicRouterInstance
}
from
'../client/router'
import
{
Router
}
from
'../client/router'
export
{
AppInitialProps
}
export
{
AppInitialProps
}
...
@@ -31,18 +30,9 @@ export default class App<P = {}, CP = {}, S = {}> extends React.Component<
...
@@ -31,18 +30,9 @@ export default class App<P = {}, CP = {}, S = {}> extends React.Component<
P
&
AppProps
<
CP
>
,
P
&
AppProps
<
CP
>
,
S
S
>
{
>
{
static
childContextTypes
=
{
router
:
PropTypes
.
object
,
}
static
origGetInitialProps
=
appGetInitialProps
static
origGetInitialProps
=
appGetInitialProps
static
getInitialProps
=
appGetInitialProps
static
getInitialProps
=
appGetInitialProps
getChildContext
()
{
return
{
router
:
makePublicRouterInstance
(
this
.
props
.
router
),
}
}
// Kept here for backwards compatibility.
// Kept here for backwards compatibility.
// When someone ended App they could call `super.componentDidCatch`.
// When someone ended App they could call `super.componentDidCatch`.
// @deprecated This method is no longer needed. Errors are caught at the top level
// @deprecated This method is no longer needed. Errors are caught at the top level
...
...
test/integration/build-stats-output/test/index.test.js
View file @
beed775e
...
@@ -9,6 +9,6 @@ const appDir = join(__dirname, '../react-site')
...
@@ -9,6 +9,6 @@ const appDir = join(__dirname, '../react-site')
describe
(
'Build Stats Output'
,
()
=>
{
describe
(
'Build Stats Output'
,
()
=>
{
it
(
'Shows correct package count in output'
,
async
()
=>
{
it
(
'Shows correct package count in output'
,
async
()
=>
{
const
{
stdout
}
=
await
nextBuild
(
appDir
,
undefined
,
{
stdout
:
true
})
const
{
stdout
}
=
await
nextBuild
(
appDir
,
undefined
,
{
stdout
:
true
})
expect
(
stdout
).
toMatch
(
/
\/
something .*
?
5
/
)
expect
(
stdout
).
toMatch
(
/
\/
something .*
?
4
/
)
})
})
})
})
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