React Corsair - v0.0.10
    Preparing search index...

    Class RouteController<Params, Data, Context>

    Manages state of a route rendered in an Outlet.

    Type Parameters

    • Params extends Dict = any

      Route params.

    • Data = any

      Data loaded by a route.

    • Context = any

      A router context.

    Index

    Accessors

    • get data(): Data

      Returns the loaded route data, or throws an error if the route isn't ready.

      Returns Data

    • get error(): any

      Returns the error that was thrown during component or data loading, or undefined if there was no error.

      Returns any

    • get status(): "error" | "loading" | "not_found" | "redirect" | "ready"

      Returns the current status of the controller:

      "loading"
      The route is being actively loaded.
      "ready"
      The route component and data were successfully loaded.
      "error"
      The route has thrown an error during rendering or from a data loader.
      "notFound"
      The route was marked as not found.
      "redirect"
      The route has requested a redirect.

      Returns "error" | "loading" | "not_found" | "redirect" | "ready"

    Constructors

    Methods

    • Instantly aborts the pending route loading for this controller.

      Parameters

      • reason: unknown = ...

        The abort reason that is used for rejection of the loading promise.

      Returns void

    • Redirects the router to a new location.

      Parameters

      • to: string | To

        A location or a URL to redirect to.

      Returns void

    • Sets the provided data and loads the route component if it's not loaded yet.

      Parameters

      • data: Data | PromiseLike<Data>

        The route data.

      Returns void

    • Sets an error and notifies router subscribers.

      Parameters

      • error: any

        The error.

      Returns void

    Properties

    childController: null | RouteController<any, any, any> = null

    A controller rendered in a nested Outlet.

    params: Params

    Route params.

    parentController: null | RouteController<any, any, any> = null

    A controller rendered in an enclosing Outlet.

    promise: null | AbortablePromise<Data> = null

    A promise that settles when the route loading is completed, or null if there's no loading in progress.

    route: Route<any, Params, Data, Context>

    The route this controller loads.

    router: Router<Context>

    The router that this controller belongs to.