リンク
- Forget React Router. Modern and clean routing with hooks
- Modern and clean routing with hooks
- Paratron/hookrouter - github
サンプル
Paratron/hookrouterのREADME.md見れば分かる
import {useRoutes} from 'hookrouter';
const routes = {
'/': () => <HomePage />,
'/about': () => <AboutPage />,
'/products': () => <ProductOverview />,
'/products/:id': ({id}) => <ProductDetails id={id} />
};
const MyApp = () => {
const routeResult = useRoutes(routes);
return routeResult || <NotFoundPage />;
}