Skip to content

getPreviousBreakpoint(): Breakpoint | undefined

The getPreviousBreakpoint method allows you to get a previously active breakpoint if it existed.

Returned value

A returned value has a type of Breakpoint | undefined where Breakpoint represents the Breakpoint model.

Example

In this example we make a ResolutionDetectorApi call to get a previously active breakpoint if it existed.

    useStorefront(async (storefront) => {
        const resolutionDetectorApi = storefront.getApiSync('ResolutionDetectorApi');

        const previousBreakpoint = resolutionDetectorApi.getPreviousBreakpoint();

        if (!previousBreakpoint) return;

        console.log(`Previous breakpoint was ${previousBreakpoint.name} which applied to screens of ${previousBreakpoint.value}px width and below.`);
    });

Resolution Detector API methods reference

Models reference