pass route params through context

This commit is contained in:
MapleLeaf
2022-01-02 20:30:04 -06:00
committed by Darius
parent 5761a3f8b0
commit 01a4201878
4 changed files with 28 additions and 6 deletions

View File

@@ -0,0 +1,13 @@
import { createContext, useContext } from "react"
export type RouteContextValue = {
routeParams: Record<string, string>
}
const Context = createContext<RouteContextValue>()
export const RouteContextProvider = Context.Provider
export function useRouteParams() {
return useContext(Context)?.routeParams ?? {}
}