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
c8bf63e7
Commit
c8bf63e7
authored
May 16, 2018
by
Lionel
Committed by
Tim Neutkens
May 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update with-url-object-routing (#4314)
Use `withRouter` HOC to avoid _deprecation warning_ using `url`
parent
6893158b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
about.js
examples/with-url-object-routing/pages/about.js
+5
-5
No files found.
examples/with-url-object-routing/pages/about.js
View file @
c8bf63e7
import
React
from
'react'
import
React
from
'react'
import
Link
from
'next/link'
import
Link
from
'next/link'
import
Router
from
'next/router'
import
Router
,
{
withRouter
}
from
'next/router'
const
href
=
{
const
href
=
{
pathname
:
'/about'
,
pathname
:
'/about'
,
...
@@ -14,10 +14,10 @@ const as = {
...
@@ -14,10 +14,10 @@ const as = {
const
handleClick
=
()
=>
Router
.
push
(
href
,
as
)
const
handleClick
=
()
=>
Router
.
push
(
href
,
as
)
export
default
(
props
)
=>
(
export
default
withRouter
(({
router
:
{
query
}
}
)
=>
(
<
div
>
<
div
>
<
h1
>
About
{
props
.
url
.
query
.
name
}
<
/h1
>
<
h1
>
About
{
query
.
name
}
<
/h1
>
{
props
.
url
.
query
.
name
===
'zeit'
?
(
{
query
.
name
===
'zeit'
?
(
<
Link
href
=
'/'
>
<
Link
href
=
'/'
>
<
a
>
Go
to
home
page
<
/a
>
<
a
>
Go
to
home
page
<
/a
>
<
/Link
>
<
/Link
>
...
@@ -25,4 +25,4 @@ export default (props) => (
...
@@ -25,4 +25,4 @@ export default (props) => (
<
button
onClick
=
{
handleClick
}
>
Go
to
/
about
/
zeit
<
/button
>
<
button
onClick
=
{
handleClick
}
>
Go
to
/
about
/
zeit
<
/button
>
)}
)}
<
/div
>
<
/div
>
)
)
)
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