pass route params through context
This commit is contained in:
13
packages/docs-new/src/route-context.tsx
Normal file
13
packages/docs-new/src/route-context.tsx
Normal 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 ?? {}
|
||||
}
|
||||
Reference in New Issue
Block a user