Skip to content

Commit a7b7ff4

Browse files
committed
Update changelog and API documentation with onUpdate changes
1 parent 3b2ab7e commit a7b7ff4

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

CHANGES.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
## [HEAD]
22

3+
## [v1.1.0]
34

5+
### Router `onUpdate` prop
6+
7+
Functions passed as the `onUpdate` prop to a `<Router />` component will be invoked with the new router state as the first argument. For example:
8+
9+
```js
10+
function handleUpdate (state) {
11+
console.log(state) // { components, location, params, routes }
12+
}
13+
14+
ReactDOM.render(<Router onUpdate={ handleUpdate }>...</Router>, el)
15+
```
16+
17+
As before this change, `onUpdate` is called within the scope of the router. So it is still possible to access router state using `this.state`.
418

519
## [v1.0.0]
620

@@ -313,7 +327,7 @@ For example, `params` is not available via context.
313327
We're developing scroll behaviors separately in the
314328
[`scroll-behavior`](https://github.com/rackt/scroll-behavior)
315329
library until we have a stable, robust implementation that we're happy with.
316-
Currently, scroll behaviors are exposed there as history enhancers:
330+
Currently, scroll behaviors are exposed there as history enhancers:
317331

318332
```js
319333
import createHistory from 'history/lib/createBrowserHistory'
@@ -350,5 +364,3 @@ To cancel a "transition from", please refer to the
350364

351365
There's a lot of the old API we've missed, please give the [new
352366
docs](/docs) a read and help us fill this guide in. Thanks!
353-
354-

docs/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ A function used to convert a query string into an object that gets passed to rou
7171
##### `onError(error)`
7272
While the router is matching, errors may bubble up, here is your opportunity to catch and deal with them. Typically these will come from async features like [`route.getComponents`](#getcomponentscallback), [`route.getIndexRoute`](#getindexroutecallback), and [`route.getChildRoutes`](#getchildrouteslocation-callback).
7373

74-
##### `onUpdate()`
75-
Called whenever the router updates its state in response to URL changes.
74+
##### `onUpdate(routerState)`
75+
Called whenever the router updates its state in response to URL changes. This new state is passed as the first argument.
7676

7777
#### Examples
7878
Please see the [`examples/`](/examples) directory of the repository for extensive examples of using `Router`.

0 commit comments

Comments
 (0)