Back to React Router

useInRouterContext

docs/api/hooks/useInRouterContext.md

7.6.2896 B
Original Source

useInRouterContext

<!-- ⚠️ ⚠️ IMPORTANT ⚠️ ⚠️ Thank you for helping improve our documentation! This file is auto-generated from the JSDoc comments in the source code, so please edit the JSDoc comments in the file below and this file will be re-generated once those changes are merged. https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx -->

[MODES: framework, data]

Summary

Reference Documentation ↗

Returns true if this component is a descendant of a Router, useful to ensure a component is used within a Router.

Signature

tsx
function useInRouterContext(): boolean

Returns

Whether the component is within a Router context