forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexRoute.js
More file actions
50 lines (42 loc) · 1.18 KB
/
IndexRoute.js
File metadata and controls
50 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import createReactClass from 'create-react-class'
import { func } from 'prop-types'
import warning from './routerWarning'
import invariant from 'invariant'
import { createRouteFromReactElement } from './RouteUtils'
import { component, components, falsy } from './InternalPropTypes'
/**
* An <IndexRoute> is used to specify its parent's <Route indexRoute> in
* a JSX route config.
*/
/* eslint-disable react/require-render-return */
const IndexRoute = createReactClass({
displayName: 'IndexRoute',
statics: {
createRouteFromReactElement(element, parentRoute) {
/* istanbul ignore else: sanity check */
if (parentRoute) {
parentRoute.indexRoute = createRouteFromReactElement(element)
} else {
warning(
false,
'An <IndexRoute> does not make sense at the root of your route config'
)
}
}
},
propTypes: {
path: falsy,
component,
components,
getComponent: func,
getComponents: func
},
/* istanbul ignore next: sanity check */
render() {
invariant(
false,
'<IndexRoute> elements are for router configuration only and should not be rendered'
)
}
})
export default IndexRoute