Skip to content

Commit

Permalink
Merge pull request remix-run#2110 from zenlambda/patch-1
Browse files Browse the repository at this point in the history
Clarify available State information in context
  • Loading branch information
mjackson committed Oct 7, 2015
2 parents 3ef848e + 09eec85 commit aabd195
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ var Assignment = React.createClass({
// if you're not a route component, you need to pass location down the
// tree or get the location from context. We will probably provide a
// higher order component that will do this for you but haven't yet.
// see further down for more information on what can be passed down
// via context
var Assignment = React.createClass({
contextTypes: {
location: React.PropTypes.object
Expand All @@ -261,13 +263,26 @@ and where you get it now if you're a route component (`this.props`)

| v0.13 (this) | v1.0 (this.props) |
|-----------------|------------------------------------|
| `getPath()` | `location.pathname+location.query` |
| `getPath()` | `location.pathname+location.search` |
| `getPathname()` | `location.pathname` |
| `getParams()` | `params` |
| `getQuery()` | `location.query` |
| `getQuery()` | `location.search` |
| `getRoutes()` | `routes` |
| `isActive(to, params, query)` | `history.isActive(pathname, query, onlyActiveOnIndex)` |

Here is another table of properties you used to get via the `State` and
where you can get it now if you are **not** a route component (`this.context`).

| v0.13 (this) | v1.0 (this.context) |
|-----------------|------------------------------------|
| `getPath()` | `location.pathname+location.search`|
| `getPathname()` | `location.pathname` |
| `getQuery()` | `location.search` |
| `isActive(to, params, query)` | `history.isActive(pathname, query, onlyActiveOnIndex)` |

Note not all `State` functionality can be accessed via context in v1.0.
For example, `params` is not available via context.

### Scrolling

In 0.13.x we had a couple of implementations to restore scroll position,
Expand Down

0 comments on commit aabd195

Please sign in to comment.