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
e45cc89c
Commit
e45cc89c
authored
Dec 19, 2016
by
Arunoda Susiripala
Committed by
Guillermo Rauch
Dec 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deprecate messages for url.replaceTo and url.pushTo (#433)
parent
a87ef1a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
README.md
README.md
+7
-5
app.js
lib/app.js
+4
-3
No files found.
README.md
View file @
e45cc89c
...
...
@@ -173,10 +173,12 @@ Each top-level component receives a `url` property with the following API:
-
`pathname`
-
`String`
of the current path excluding the query string
-
`query`
-
`Object`
with the parsed query string. Defaults to
`{}`
-
`push(url
)`
- performs a
`pushState`
call associated with the current component
-
`replace(url
)`
- performs a
`replaceState`
call associated with the current component
-
`push(url
, as=url)`
- performs a
`pushState`
call with the given url
-
`replace(url
, as=url)`
- performs a
`replaceState`
call with the given url
#### Imperatively
The second
`as`
parameter for
`push`
and
`replace`
is an optional _decoration_ of the URL. Useful if you configured custom routes on the server.
#### Imperatively
You can also do client-side page transitions using the
`next/router`
...
...
@@ -193,8 +195,8 @@ Above `Router` object comes with the following API:
-
`route`
-
`String`
of the current route
-
`pathname`
-
`String`
of the current path excluding the query string
-
`query`
-
`Object`
with the parsed query string. Defaults to
`{}`
-
`push(url, as=url)`
- performs a
`pushState`
call
associated with the current component
-
`replace(url, as=url)`
- performs a
`replaceState`
call
associated with the current component
-
`push(url, as=url)`
- performs a
`pushState`
call
with the given url
-
`replace(url, as=url)`
- performs a
`replaceState`
call
with the given url
The second
`as`
parameter for
`push`
and
`replace`
is an optional _decoration_ of the URL. Useful if you configured custom routes on the server.
...
...
lib/app.js
View file @
e45cc89c
...
...
@@ -61,20 +61,21 @@ export default class App extends Component {
function
propsToState
(
props
)
{
const
{
Component
,
router
}
=
props
const
{
route
}
=
router
const
url
=
{
query
:
router
.
query
,
pathname
:
router
.
pathname
,
back
:
()
=>
router
.
back
(),
push
:
(
url
)
=>
router
.
push
(
route
,
url
),
push
:
(
url
,
as
)
=>
router
.
push
(
url
,
as
),
pushTo
:
(
href
,
as
)
=>
{
console
.
warn
(
`Warning: 'url.pushTo()' is deprecated. Please use 'url.push()' instead.`
)
const
pushRoute
=
as
?
href
:
null
const
pushUrl
=
as
||
href
return
router
.
push
(
pushRoute
,
pushUrl
)
},
replace
:
(
url
)
=>
router
.
replace
(
route
,
url
),
replace
:
(
url
,
as
)
=>
router
.
replace
(
url
,
as
),
replaceTo
:
(
href
,
as
)
=>
{
console
.
warn
(
`Warning: 'url.replaceTo()' is deprecated. Please use 'url.replace()' instead.`
)
const
replaceRoute
=
as
?
href
:
null
const
replaceUrl
=
as
||
href
...
...
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