Skip to main content

useMatch

还没翻译译自英文(reactrouter.com)本页 13 段都还没译

useMatch

Framework Data Declarative

Summary

Reference Documentation ↗

Returns a PathMatch object if the given pattern matches the current URL. This is useful for components that need to know "active" state, e.g. <NavLink>.

Signature

function useMatch<Path extends string>(
  pattern: PathPattern<Path> | Path,
): PathMatch<ParamParseKey<Path>> | null

Params

pattern

The pattern to match against the current Location

Returns

The path match object if the pattern matches, null otherwise