React Router API Reference
    Preparing search index...

    Interface DataStrategyMatch

    interface DataStrategyMatch {
        params: Params<ParamKey>;
        pathname: string;
        pathnameBase: string;
        resolve: (
            handlerOverride?: (handler: (ctx?: unknown) => unknown) => unknown,
        ) => Promise<DataStrategyResult>;
        route: AgnosticDataRouteObject;
        shouldLoad: boolean;
        shouldRevalidateArgs: null | ShouldRevalidateFunctionArgs;
        shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
    }

    Hierarchy

    • AgnosticRouteMatch<string, AgnosticDataRouteObject>
      • DataStrategyMatch
    Index

    Properties

    params: Params<ParamKey>

    The names and values of dynamic parameters in the URL.

    pathname: string

    The portion of the URL pathname that was matched.

    pathnameBase: string

    The portion of the URL pathname that was matched before child routes.

    resolve: (
        handlerOverride?: (handler: (ctx?: unknown) => unknown) => unknown,
    ) => Promise<DataStrategyResult>

    An async function that will resolve any route.lazy implementations and execute the route's handler (if necessary), returning a DataStrategyResult

    • Calling match.resolve does not mean you're calling the action/loader (the "handler") - resolve will only call the handler internally if needed and if you don't pass your own handlerOverride function parameter
    • It is safe to call match.resolve for all matches, even if they have shouldLoad=false, and it will no-op if no loading is required
    • You should generally always call match.resolve() for shouldLoad:true routes to ensure that any route.lazy implementations are processed
    • See the examples below for how to implement custom handler execution via match.resolve
    route: AgnosticDataRouteObject

    The route object that was used to match.

    shouldLoad: boolean

    Deprecated in favor of shouldCallHandler

    A boolean value indicating whether this route handler should be called in this pass.

    The matches array always includes all matched routes even when only some route handlers need to be called so that things like middleware can be implemented.

    shouldLoad is usually only interesting if you are skipping the route handler entirely and implementing custom handler logic - since it lets you determine if that custom logic should run for this route or not.

    For example:

    • If you are on /parent/child/a and you navigate to /parent/child/b - you'll get an array of three matches ([parent, child, b]), but only b will have shouldLoad=true because the data for parent and child is already loaded
    • If you are on /parent/child/a and you submit to a's action, then only a will have shouldLoad=true for the action execution of dataStrategy
    • After the action, dataStrategy will be called again for the loader revalidation, and all matches will have shouldLoad=true (assuming no custom shouldRevalidate implementations)
    shouldRevalidateArgs: null | ShouldRevalidateFunctionArgs

    Arguments passed to the shouldRevalidate function for this loader execution. Will be null if this is not a revalidating loader DataStrategyMatch.

    Methods

    • Determine if this route's handler should be called during this dataStrategy execution. Calling it with no arguments will leverage the default revalidation behavior. You can pass your own defaultShouldRevalidate value if you wish to change the default revalidation behavior with your dataStrategy.

      Parameters

      • OptionaldefaultShouldRevalidate: boolean

        defaultShouldRevalidate override value (optional)

      Returns boolean