Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Update changelog and API documentation with onUpdate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nhunzaker committed Nov 11, 2015
1 parent 3b2ab7e commit a7b7ff4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
## [HEAD]

## [v1.1.0]

### Router `onUpdate` prop

Functions passed as the `onUpdate` prop to a `<Router />` component will be invoked with the new router state as the first argument. For example:

```js
function handleUpdate (state) {
console.log(state) // { components, location, params, routes }
}

ReactDOM.render(<Router onUpdate={ handleUpdate }>...</Router>, el)
```

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`.

## [v1.0.0]

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

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

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


4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ A function used to convert a query string into an object that gets passed to rou
##### `onError(error)`
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).

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

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

0 comments on commit a7b7ff4

Please sign in to comment.