Provides several react hooks.
Hooks for reactive URL
.
import { Router, useURL } from "@miyauci/react-router";
<Router>
<Html />
</Router>;
function Html() {
const url = useURL();
return null;
}
If it call outside of Router
, it throws error.
Hooks for matching result.
import { Route, useURLPatternResult } from "@miyauci/react-router";
<Route pathname="/users/:id">
<User />
</Route>;
function User() {
const result = useURLPatternResult();
const id = result.pathname.groups.id;
return null;
}
If it call outside of Route
, it throws error.