Options
All
  • Public
  • Public/Protected
  • All
Menu

A convenience type creating the state object to be stored in history.state. Contains a {@link State#publicState} field where the public state is stored, And a field where Router's private state is stored, which can be accessed using the {@link ROUTER_PRIVATE_STATE_KEY} constant.

This goes without saying, the private state is not meant to be tampered with.

Hierarchy

  • State

Index

Constructors

  • new State(unknownState: any): State
  • throws

    {@link RouterError} if the object is not a valid state.

    Parameters

    • unknownState: any

      the object to create the state from.

    Returns State

Properties

__ROUTER_PRIVATE_STATE_KEY_DO_NOT_TAMPER__: RouterPrivateState

The private state to be used internally by Router.

publicState?: unknown

The public state for clients to access. Only serializable types (e.g. Numbers and Strings) are supported.

default

null

Can be accessed by {@link RouteContext#state}

Methods

  • [hasInstance](unknownState: any): unknownState is State
  • Returns true if the given object is a valid state object. Uses the {@link State#isValid} method under the hood.

    Parameters

    • unknownState: any

      the object to validate

    Returns unknownState is State

  • A factory method that creates a new state object with the given private state. It is used by Router to create a new state object when a new path is entered or when the popstate event is fired.

    Parameters

    Returns State

  • isValid(unknownState: any): unknownState is State
  • Returns true if the given object is a valid state object.

    Parameters

    • unknownState: any

      the object to validate

    Returns unknownState is State

Generated using TypeDoc