Skip to content

Commit f39c294

Browse files
committed
Minor fixes for CHANGES
1 parent 5da72f0 commit f39c294

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

CHANGES.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
### Changes to context exports and Mixins
44

5-
Only an object named `router` is added to context. Accessing `context.history`, `context.location`, and `context.route` are all deprecated.
5+
Only an object named `router` is added to context. Accessing `context.history`,
6+
`context.location`, and `context.route` are all deprecated.
67

78
Additionally, since `context` is now documented, all mixins are deprecated.
89

@@ -31,32 +32,55 @@ it's up to you.
3132

3233
#### Navigating
3334

34-
In all cases where you once had a `history` for navigation, you now have a `router` to navigate instead.
35+
In all cases where you once had a `history` for navigation, you now have a
36+
`router` to navigate instead.
3537

3638
```js
37-
// v1.0.0
39+
// v1.0.x
3840
history.pushState(state, path, query)
3941
history.replaceState(state, path, query)
4042

41-
// v1.1.0
43+
// v2.0.0
4244
router.push(path)
43-
router.push({ path, query, state }) // new "location descriptor"
45+
router.push({ pathname, query, state }) // new "location descriptor"
4446

4547
router.replace(path)
46-
router.replace({ path, query, state }) // new "location descriptor"
48+
router.replace({ pathname, query, state }) // new "location descriptor"
49+
```
50+
51+
#### Links
52+
53+
`<Link to>`s now takes a location descriptor. The other props are deprecated.
54+
55+
```js
56+
// v1.0.x
57+
<Link to="/foo" query={{ the: 'query' }}>
58+
59+
// v2.0.0
60+
<Link to={{ pathname: '/foo', query: { the: 'query' } }}>
61+
```
62+
63+
For custom link-like components, the same applies for `router.isActive`.
64+
65+
```js
66+
// v1.0.x
67+
router.isActive(pathname, query, indexOnly)
68+
69+
// v2.0.0
70+
router.isActive({ pathname, query }, indexOnly)
4771
```
4872

4973
#### Navigating in route components
5074

5175
```js
52-
// v1.0.0
76+
// v1.0.x
5377
class RouteComponent extends React.Component {
5478
someHandler() {
5579
this.props.history.pushState(...)
5680
}
5781
}
5882

59-
// v1.1.0
83+
// v2.0.0
6084
class RouteComponent extends React.Component {
6185
someHandler() {
6286
this.props.router.push(...)
@@ -67,7 +91,7 @@ class RouteComponent extends React.Component {
6791
#### Navigating inside deeply nested components
6892

6993
```js
70-
// v1.0.0
94+
// v1.0.x
7195
const DeepComponent = React.createClass({
7296
mixins: [ History ],
7397

@@ -76,7 +100,7 @@ const DeepComponent = React.createClass({
76100
}
77101
}
78102

79-
// v1.1.0
103+
// v2.0.0
80104
// You have a couple options:
81105
// Use context directly (recommended)
82106
const DeepComponent = React.createClass({
@@ -119,15 +143,15 @@ const DeepComponent = React.createClass({
119143
#### Lifecycle Mixin with route components
120144
121145
```js
122-
// v1.0.0
146+
// v1.0.x
123147
const RouteComponent = React.createClass({
124148
mixins: [ Lifecycle ],
125149
routerWillLeave() {
126150
// ...
127151
}
128152
})
129153

130-
// v1.1.0
154+
// v2.0.0
131155
const RouteComponent = React.createClass({
132156
componentDidMount() {
133157
const { router, route } = this.props
@@ -138,18 +162,22 @@ const RouteComponent = React.createClass({
138162
// or make your own mixin, check it out in the next section
139163
```
140164
165+
You don't need to manually tear down the route leave hook in most cases any
166+
more. We automatically remove all attached route leave hooks after leaving the
167+
associated route.
168+
141169
#### Lifecycle Mixin with deep, non-route components
142170
143171
```js
144-
// v1.0.0
172+
// v1.0.x
145173
const DeepComponent = React.createClass({
146174
mixins: [ Lifecycle ],
147175
routerWillLeave() {
148176
// do stuff
149177
}
150178
})
151179

152-
// v1.1.0
180+
// v2.0.0
153181
// you have a couple of options
154182
// first you can put the route on context in the route component
155183
const RouteComponent = React.createClass({
@@ -201,7 +229,7 @@ Just a stub so we don't forget to talk about it.
201229
```js
202230
// v1.0.x
203231
import { RoutingContext } from 'react-router'
204-
// v1.1.0
232+
// v2.0.0
205233
import { RouterContext } from 'react-router'
206234
```
207235

0 commit comments

Comments
 (0)