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
db5b3dc8
Unverified
Commit
db5b3dc8
authored
Apr 22, 2019
by
Luis Fernando Alvarez D
Committed by
GitHub
Apr 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update types for with-router (#7106)
* Updated declarations for with-router
parent
baabfbd7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
with-router.tsx
packages/next/client/with-router.tsx
+13
-3
No files found.
packages/next/client/with-router.tsx
View file @
db5b3dc8
import
React
from
'react'
import
React
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
NextComponentType
,
IContext
}
from
'next-server/dist/lib/utils'
import
{
IPublicRouterInstance
}
from
'./router'
;
export
default
function
withRouter
(
ComposedComponent
:
React
.
ComponentType
<
any
>
&
{
getInitialProps
?:
any
})
{
export
type
WithRouterProps
=
{
class
WithRouteWrapper
extends
React
.
Component
{
router
:
IPublicRouterInstance
,
}
export
type
ExcludeRouterProps
<
P
>
=
Pick
<
P
,
Exclude
<
keyof
P
,
keyof
WithRouterProps
>>
export
default
function
withRouter
<
P
extends
WithRouterProps
,
C
=
IContext
>
(
ComposedComponent
:
NextComponentType
<
C
,
any
,
P
>
):
React
.
ComponentClass
<
ExcludeRouterProps
<
P
>>
{
class
WithRouteWrapper
extends
React
.
Component
<
ExcludeRouterProps
<
P
>>
{
static
displayName
?:
string
static
displayName
?:
string
static
getInitialProps
?:
any
static
getInitialProps
?:
any
static
contextTypes
=
{
static
contextTypes
=
{
router
:
PropTypes
.
object
,
router
:
PropTypes
.
object
,
}
}
context
!
:
WithRouterProps
render
()
{
render
()
{
return
<
ComposedComponent
return
<
ComposedComponent
router=
{
this
.
context
.
router
}
router=
{
this
.
context
.
router
}
{
...
this
.
props
}
{
...
this
.
props
as
any
}
/>
/>
}
}
}
}
...
...
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