react-swipeable-routes
Utility for integrating react-swipeable-views with react-router.
Example
Notice how the url changes when swipping.
This example is available on /example.
Usage
Any additional props will be passed down to SwipeableViews
:
Replace url instead of push
You can add a replace
prop to SwipeableRoutes
and it will replace location instead of pushing it when swiping.
Scroll to top on swipe
Routes with parameters
You can include routes with parameters in the path. However, you can't swipe to them directly, you have to enter through a link or a url change. If you want to be able to swipe to them, you can include a defaultParams
props specifying the default parameters for when swipping to them.
Unlike react-router, with react-swipeable-routes all routes have to be rendered at all times. Because of that, unlike react-router, in which your component gets a match object only if there was a match, here your rendered component will always receive a match
prop with same structure as the match
prop in react-router except for one difference: it includes a type object indicating what type of match it is:
none
: The view was never rendered and its parameters are the specified defaults.outOfView
: The view has different parameters than default, but it's currently out of the screen.full
: The view is currently on screen an it has different parameters than default.