-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
161 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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, | ||
push: func.isRequired, | ||
replace: func.isRequired, | ||
go: func.isRequired, | ||
goBack: func.isRequired, | ||
goForward: func.isRequired | ||
}) | ||
|
||
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) ]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,78 @@ | ||
import { PropTypes } from 'react' | ||
|
||
const { func, object, arrayOf, oneOfType, element, shape, string } = PropTypes | ||
import deprecateObjectProperties from './deprecateObjectProperties' | ||
import * as InternalPropTypes from './InternalPropTypes' | ||
import warning from './routerWarning' | ||
|
||
export function falsy(props, propName, componentName) { | ||
if (props[propName]) | ||
return new Error(`<${componentName}> should not have a "${propName}" prop`) | ||
} | ||
const { func, object, shape, string } = PropTypes | ||
|
||
export const history = shape({ | ||
listen: func.isRequired, | ||
export const routerShape = shape({ | ||
push: func.isRequired, | ||
replace: func.isRequired, | ||
go: func.isRequired, | ||
goBack: func.isRequired, | ||
goForward: func.isRequired | ||
goForward: func.isRequired, | ||
setRouteLeaveHook: func.isRequired, | ||
isActive: func.isRequired | ||
}) | ||
|
||
export const location = shape({ | ||
export const locationShape = 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) ]) | ||
// Deprecated stuff below: | ||
|
||
export const router = shape({ | ||
push: func.isRequired, | ||
replace: func.isRequired, | ||
go: func.isRequired, | ||
goBack: func.isRequired, | ||
goForward: func.isRequired, | ||
setRouteLeaveHook: func.isRequired, | ||
isActive: func.isRequired | ||
}) | ||
export let falsy = InternalPropTypes.falsy | ||
export let history = InternalPropTypes.history | ||
export let location = locationShape | ||
export let component = InternalPropTypes.component | ||
export let components = InternalPropTypes.components | ||
export let route = InternalPropTypes.route | ||
export let routes = InternalPropTypes.routes | ||
export let router = routerShape | ||
|
||
if (__DEV__) { | ||
const deprecatePropType = (propType, message) => (...args) => { | ||
warning(false, message) | ||
return propType(...args) | ||
} | ||
|
||
const deprecateInternalPropType = propType => ( | ||
deprecatePropType(propType, 'This prop type is not intended for external use, and was previously exported by mistake. These internal prop types are deprecated for external use, and will be removed in a later version.') | ||
) | ||
|
||
const deprecateRenamedPropType = (propType, name) => ( | ||
deprecatePropType(propType, `The \`${name}\` prop type is now exported as \`${name}Shape\` to avoid name conflicts. This export is deprecated and will be removed in a later version.`) | ||
) | ||
|
||
falsy = deprecateInternalPropType(falsy) | ||
history = deprecateInternalPropType(history) | ||
component = deprecateInternalPropType(component) | ||
components = deprecateInternalPropType(components) | ||
route = deprecateInternalPropType(route) | ||
routes = deprecateInternalPropType(routes) | ||
|
||
export default { | ||
location = deprecateRenamedPropType(location, 'location') | ||
router = deprecateRenamedPropType(router, 'router') | ||
} | ||
|
||
let defaultExport = { | ||
falsy, | ||
history, | ||
location, | ||
component, | ||
components, | ||
route, | ||
// For some reason, routes was never here. | ||
router | ||
} | ||
|
||
if (__DEV__) { | ||
defaultExport = deprecateObjectProperties(defaultExport, 'The default export from `react-router/lib/PropTypes` is deprecated. Please use the named exports instead.') | ||
} | ||
|
||
export default defaultExport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.