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

    Interface BrowserHistory

    A browser history abstraction.

    interface BrowserHistory {
        canGoBack: boolean;
        location: Location;
        url: string;
        back(): void;
        block(blocker: HistoryBlocker): () => void;
        forward(): void;
        go(delta: number): void;
        parseURL(url: string): Location;
        push(to: string | To): void;
        replace(to: string | To): void;
        start(): () => void;
        subscribe(listener: () => void): () => void;
        toURL(to: To): string;
    }

    Hierarchy (View Summary)

    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

      • to: string | To

        A location or a URL to navigate to.

      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

      • to: string | To

        A location or a URL to navigate to.

      Returns void

      const userRoute = createRoute('/users/:userId');

      history.replace(userRoute.getLocation({ userId: 42 }));
      // or
      history.replace('/users/42');
    • Adds required DOM listeners.

      Returns () => void

      A callback that removes DOM listeners.

    • Subscribe to location changes.

      Parameters

      • listener: () => void

        A listener to subscribe.

      Returns () => void

      A callback to unsubscribe a listener.

    • Converts a location to a URL string.

      Parameters

      Returns string

    Properties

    canGoBack: boolean

    true if back would certainly move back one page in the history.

    location: Location

    The current location.

    url: string

    A URL that represents the current location.