Skip to content

Commit

Permalink
Update tests and docs for Router.PropTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Apr 12, 2016
1 parent 5a9692d commit cfe479f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You need to add `router` to your component's `contextTypes` to make the router o

```js
contextTypes: {
router: React.PropTypes.object.isRequired
router: Router.PropTypes.router
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/ConfirmingNavigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can prevent a transition from happening or prompt the user before leaving a
const Home = React.createClass({

contextTypes: {
router: React.PropTypes.object
router: Router.PropTypes.router
},

componentDidMount() {
Expand Down
3 changes: 2 additions & 1 deletion modules/__tests__/RouterContext-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { render, unmountComponentAtNode } from 'react-dom'

import match from '../match'
import { router as routerPropType } from '../PropTypes'
import RouterContext from '../RouterContext'
import { createRouterObject } from '../RouterUtils'

Expand Down Expand Up @@ -41,7 +42,7 @@ describe('RouterContext', () => {
}

Component.contextTypes = {
router: React.PropTypes.object.isRequired
router: routerPropType.isRequired
}

routes = { path: '/', component: Component }
Expand Down
5 changes: 3 additions & 2 deletions modules/__tests__/transitionHooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import expect, { spyOn } from 'expect'
import React, { Component } from 'react'
import { render, unmountComponentAtNode } from 'react-dom'
import createHistory from '../createMemoryHistory'
import { router as routerPropType } from '../PropTypes'
import execSteps from './execSteps'
import Router from '../Router'

Expand Down Expand Up @@ -42,7 +43,7 @@ describe('When a router enters a branch', function () {
}

NewsFeed.contextTypes = {
router: React.PropTypes.object.isRequired
router: routerPropType.isRequired
}

class Inbox extends Component {
Expand Down Expand Up @@ -71,7 +72,7 @@ describe('When a router enters a branch', function () {
}

User.contextTypes = {
router: React.PropTypes.object.isRequired
router: routerPropType.isRequired
}

NewsFeedRoute = {
Expand Down
10 changes: 5 additions & 5 deletions upgrade-guides/v2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Access `location` from `this.props.location` of your `Route` component. If you'd
// v2.0.x
const RouteComponent = React.createClass({
childContextTypes: {
location: React.PropTypes.object
location: Router.PropTypes.location
},

getChildContext() {
Expand All @@ -136,7 +136,7 @@ const RouteComponent = React.createClass({
// 2.0.0
const RouteComponent = React.createClass({
contextTypes: {
route: React.PropTypes.object
route: Router.PropTypes.route
},
getChildContext() {
return {
Expand All @@ -160,7 +160,7 @@ const RouteComponent = React.createClass({
// v2.0.0
const RouteComponent = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: Router.PropTypes.router.isRequired
},
componentDidMount() {
const { route } = this.props
Expand Down Expand Up @@ -204,7 +204,7 @@ const RouteComponent = React.createClass({
// v2.0.0
const RouteComponent = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: Router.PropTypes.router.isRequired
},
someHandler() {
this.context.router.push(...)
Expand All @@ -229,7 +229,7 @@ const DeepComponent = React.createClass({
// 1) Use context.router (especially if on the server)
const DeepComponent = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: Router.PropTypes.router.isRequired
},
handleSubmit() {
this.context.router.push(...)
Expand Down

0 comments on commit cfe479f

Please sign in to comment.