Skip to content

Instantly share code, notes, and snippets.

@michalklim
Created June 28, 2018 12:48
Show Gist options
  • Save michalklim/bd8d0712ffa7c200e2d172e493fa27e0 to your computer and use it in GitHub Desktop.
Save michalklim/bd8d0712ffa7c200e2d172e493fa27e0 to your computer and use it in GitHub Desktop.
React Router shapes
import PropTypes from 'prop-types'
export const locationShape = PropTypes.shape({
pathname: PropTypes.string.isRequired,
search: PropTypes.string.isRequired,
hash: PropTypes.string.isRequired,
state: PropTypes.object,
});
export const historyShape = PropTypes.shape({
action: PropTypes.string.isRequired,
block: PropTypes.func.isRequired,
createHref: PropTypes.func.isRequired,
go: PropTypes.func.isRequired,
goBack: PropTypes.func.isRequired,
goForward: PropTypes.func.isRequired,
listen: PropTypes.func.isRequired,
length: PropTypes.number.isRequired,
push: PropTypes.func.isRequired,
replace: PropTypes.func.isRequired,
location: locationShape.isRequired,
});
export const matchShape = PropTypes.shape({
isExact: PropTypes.bool.isRequired,
path: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
params: PropTypes.object,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment