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

    Interface History

    A history abstraction.

    interface History {
        location: Location;
        url: string;
        back(): void;
        block(blocker: HistoryBlocker): () => void;
        forward(): void;
        go(delta: number): void;
        push(to: string | To): void;
        replace(to: string | To): void;
        subscribe(listener: () => void): () => void;
        toAbsoluteURL(to: string | To): string;
        toURL(to: To): string;
    }
    Index

    Methods

    • Move back one page in the history.

      Returns void

    • Registers a blocker that prevents navigation with history.

      Parameters

      Returns () => void

      A callback that removes blocker.

    • Move forward one page in the history.

      Returns void

    • Move forwards and backwards through the history depending on the delta.

      Parameters

      • delta: number

        The position in the history to which you want to move, relative to the current page. A negative value moves backwards, a positive value moves forwards.

      Returns void

    • Adds an entry to the history stack.

      Parameters

      Returns void

      const userRoute = createRoute('/users/:userId');
      history.push(userRoute.getLocation({ userId: 42 }));
      // or
      history.push('/users/42');
    • Modifies the current history entry, replacing it with the state object and URL passed in the method parameters.

      Parameters

      Returns void

      const userRoute = createRoute('/users/:userId');
      history.replace(userRoute.getLocation({ userId: 42 }));
      // or
      history.replace('/users/42');
    • Subscribe to location changes.

      Parameters

      • listener: () => void

        A listener to subscribe.

      Returns () => void

      A callback to unsubscribe a listener.

    • Creates an absolute URL for a given location. If history was initialized with a basePathname then it is prepended to the returned URL.

      Note: The returned URL is incompatible with push and replace methods.

      Parameters

      Returns string

    • Returns a history-local URL.

      This URL can be passed to push and replace as an argument.

      Parameters

      Returns string

    Properties

    location: Location

    The current history location.

    url: string

    A history-local URL that represents location.