Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RouteContext

Exposes properties and methods for retrieving and modifying the current route context. This is passed as the first argument of the callbacks registered using {@link Router#route}.

example
const router = new Router(new BrowserHistory());

router.route("/", (context) => {

// the first argument in this callback is the RouteContext instance
// retrieve information about the current route

const userId = context.params.getString("userId");
});

Hierarchy

  • RouteContext

Index

Constructors

Properties

hash: string

The hash segment (includes the leading hash symbol ('#'))

matched: string

The part of the pathname which is matched by the route path pattern. Empty string if the pathname hasn't been matched yet. You should not set this property manually. It is populated by the router.

param: StringMap

Exposes methods for retrieving information about the pathname segment. It is an instance of StringMap

path: string

The full path (pathname + query string + hash)

pathname: string

The pathname segment (includes the leading forward slash ('/'))

query: URLSearchParams

The URL.searchParams object parsed from the url

see

https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams

queryString: string

The query string segment (includes the leading question mark ('?'))

Accessors

  • get state(): unknown
  • set state(state: unknown): void
  • get unmatched(): string

Methods

  • saveState(): void
  • Saves the state to the history object. This method is called automatically when the state is changed.

    Returns void

Generated using TypeDoc