Skip to content

Commit a11a10b

Browse files
taiontimdorr
authored andcommitted
Clean up exported PropTypes (#3349)
1 parent 9936099 commit a11a10b

File tree

21 files changed

+119
-63
lines changed

21 files changed

+119
-63
lines changed

docs/API.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,11 @@ One or many [`<Route>`](#route)s or [`PlainRoute`](#plainroute)s.
680680

681681

682682
### `PropTypes`
683-
The following objects are exposed as properties of the exported PropTypes object:
684-
- `falsy`: Checks that a component does not have a prop
685-
- `history`
686-
- `location`
687-
- `component`
688-
- `components`
689-
- `route`
690-
- `routes`
683+
The following prop types are exported at top level and from `react-router/lib/PropTypes`:
684+
- `routerShape`: Shape for the `router` object on context
685+
- `locationShape`: Shape for the `location` object on route component props
686+
687+
Previously, a number of prop types intended for internal use were also exported under `PropTypes`. These are deprecated and should not be used.
691688

692689

693690
### `useRoutes(createHistory)` (deprecated)

docs/Troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You need to add `router` to your component's `contextTypes` to make the router o
66

77
```js
88
contextTypes: {
9-
router: Router.PropTypes.router
9+
router: routerShape.isRequired
1010
}
1111
```
1212

docs/guides/ConfirmingNavigation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You can prevent a transition from happening or prompt the user before leaving a
66
const Home = React.createClass({
77

88
contextTypes: {
9-
router: Router.PropTypes.router
9+
router: routerShape.isRequired
1010
},
1111

1212
componentDidMount() {

examples/auth-flow-async-with-query-params/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import React, { createClass, PropTypes } from 'react'
1+
import React, { createClass } from 'react'
22
import { render } from 'react-dom'
3-
import { Router, Route, IndexRoute, browserHistory, Link } from 'react-router'
3+
import {
4+
Router, Route, IndexRoute, browserHistory, Link, routerShape
5+
} from 'react-router'
46

57
function App(props) {
68
return (
@@ -12,7 +14,7 @@ function App(props) {
1214

1315
const Form = createClass({
1416
contextTypes: {
15-
router: PropTypes.object.isRequired
17+
router: routerShape.isRequired
1618
},
1719

1820
getInitialState() {

examples/auth-flow/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { render } from 'react-dom'
3-
import { browserHistory, Router, Route, Link } from 'react-router'
3+
import { browserHistory, Router, Route, Link, routerShape } from 'react-router'
44
import auth from './auth'
55

66
const App = React.createClass({
@@ -58,7 +58,7 @@ const Dashboard = React.createClass({
5858
const Login = React.createClass({
5959

6060
contextTypes: {
61-
router: React.PropTypes.object.isRequired
61+
router: routerShape.isRequired
6262
},
6363

6464
getInitialState() {

examples/confirming-navigation/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { render } from 'react-dom'
3-
import { browserHistory, Router, Route, Link } from 'react-router'
3+
import { browserHistory, Router, Route, Link, routerShape } from 'react-router'
44

55
const App = React.createClass({
66
render() {
@@ -24,7 +24,7 @@ const Dashboard = React.createClass({
2424

2525
const Form = React.createClass({
2626
contextTypes: {
27-
router: React.PropTypes.object.isRequired
27+
router: routerShape.isRequired
2828
},
2929

3030
componentWillMount() {

examples/master-detail/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react'
22
import { render, findDOMNode } from 'react-dom'
3-
import { browserHistory, Router, Route, IndexRoute, Link } from 'react-router'
3+
import {
4+
browserHistory, Router, Route, IndexRoute, Link, routerShape
5+
} from 'react-router'
46
import ContactStore from './ContactStore'
57
import './app.css'
68

@@ -63,7 +65,7 @@ const Index = React.createClass({
6365

6466
const Contact = React.createClass({
6567
contextTypes: {
66-
router: React.PropTypes.object.isRequired
68+
router: routerShape.isRequired
6769
},
6870

6971
getStateFromStore(props) {
@@ -120,7 +122,7 @@ const Contact = React.createClass({
120122

121123
const NewContact = React.createClass({
122124
contextTypes: {
123-
router: React.PropTypes.object.isRequired
125+
router: routerShape.isRequired
124126
},
125127

126128
createContact(event) {

examples/passing-props-to-children/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react'
22
import { render } from 'react-dom'
3-
import { browserHistory, Router, Route, Link } from 'react-router'
3+
import { browserHistory, Router, Route, Link, routerShape } from 'react-router'
44
import './app.css'
55

66
const App = React.createClass({
77
contextTypes: {
8-
router: React.PropTypes.object.isRequired
8+
router: routerShape.isRequired
99
},
1010

1111
getInitialState() {

modules/History.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warning from './routerWarning'
2-
import { history } from './PropTypes'
2+
import { history } from './InternalPropTypes'
33

44
/**
55
* A mixin that adds the "history" instance variable to components.

modules/IndexRedirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import warning from './routerWarning'
33
import invariant from 'invariant'
44
import Redirect from './Redirect'
5-
import { falsy } from './PropTypes'
5+
import { falsy } from './InternalPropTypes'
66

77
const { string, object } = React.PropTypes
88

0 commit comments

Comments
 (0)