forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropTypes.js
More file actions
37 lines (31 loc) · 890 Bytes
/
Copy pathPropTypes.js
File metadata and controls
37 lines (31 loc) · 890 Bytes
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
import { PropTypes } from 'react'
const { func, object, arrayOf, oneOfType, element, shape, string } = PropTypes
export function falsy(props, propName, componentName) {
if (props[propName])
return new Error(`<${componentName}> should not have a "${propName}" prop`)
}
export const history = shape({
listen: func.isRequired,
pushState: func.isRequired,
replaceState: func.isRequired,
go: func.isRequired
})
export const location = shape({
pathname: string.isRequired,
search: string.isRequired,
state: object,
action: string.isRequired,
key: string
})
export const component = oneOfType([ func, string ])
export const components = oneOfType([ component, object ])
export const route = oneOfType([ object, element ])
export const routes = oneOfType([ route, arrayOf(route) ])
export default {
falsy,
history,
location,
component,
components,
route
}