@coveo/headless-react
    Preparing search index...

    Interface Context

    The Context controller exposes methods for managing the global context in a commerce interface.

    interface Context {
        state: ContextState;
        setCountry(country: string): void;
        setCurrency(currency: CurrencyCodeISO4217): void;
        setLanguage(language: string): void;
        setLocation(location: UserLocation): void;
        setView(view: View): void;
        subscribe(listener: () => void): Unsubscribe;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Sets the country.

      Parameters

      • country: string

        The new country.

      Returns void

    • Sets the currency.

      Parameters

      • currency: CurrencyCodeISO4217

        The new currency.

      Returns void

    • Sets the language.

      Parameters

      • language: string

        The new language.

      Returns void

    • Sets the location.

      Parameters

      Returns void

    • Sets the view.

      Parameters

      • view: View

        The new view.

      Returns void

    • Adds a callback that's invoked on state change.

      Parameters

      • listener: () => void

        A callback that's invoked on state change.

      Returns Unsubscribe

      A function to remove the listener.

    Properties

    A scoped and simplified part of the headless state that is relevant to the Context controller.