Get your params typed from the route
useRouteParams
is a hook which, used with react-router-dom v6
, allows you to directly get the typed params from a provided route path.
Supposing that you already have react-router-dom
installed:
yarn add @getaround-eu/use-route-params
# or
npm -i @getaround-eu/use-route-params
import useRouteParams from "@getaround-eu/use-route-params"
const MY_COMPONENT_PATH = "/here/:is/:a/route/toMyComponent"
const MyComponent = () => {
const { a, is } = useRouteParams(MY_COMPONENT_PATH)
return (...)
}
// This way the route is always bound to the component
MyComponent.routePath = MY_COMPONENT_PATH
export default MyComponent
Getaround connects safe, convenient and affordable cars with people who need them to live and work. We aim to create the world's best carsharing marketplace that make sharing vehicles superior to owning them. Our community includes people who rely on our cars for on-demand mobility, and owners who share cars on our platform, including those who operate their own carsharing businesses.
Our vision is to make our cities and communities better places to live by:
- Empowering people with convenient access to the cars they need, whenever they need them.
- Improving mobility by relieving congestion and making public transit easier to use.
- Protecting our environment by reducing pollution and advancing sustainable energy.
As a reminder the biggest carbon emitter in most countries are the cars, and this is what we have an impact on at Getaround.