# All files / src/snackbar useRemoveToast.ts

100% Statements 28/28
100% Branches 3/3
100% Functions 1/1
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    291x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    17x
    17x
    8x
    8x
    8x
    8x
    9x
    9x
    9x
     import { createContext, useContext } from "react";
    import type { CurrentToastActions } from "./ToastManagerProvider";

    const context = createContext<CurrentToastActions | null>(null);
    context.displayName = "CurrentToastActions";

    /**
     * @remarks \@since 6.0.0
     * @internal
     */
    export const { Provider: CurrentToastActionsProvider } = context;

    /**
     * This is only required if you have multiple `Snackbar` implementations in your
     * app.
     *
     * @remarks \@since 6.0.0
     */
    export function useCurrentToastActions(): CurrentToastActions {
      const actions = useContext(context);
      if (!actions) {
        throw new Error(
          "The `CurrentToastActionsProvider` has not been initialized"
        );
      }

      return actions;
    }