From 9f5d77eeb00b3e46428b251af4f53aa463d20ec6 Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:00:20 -0400 Subject: [PATCH] feat(useToastContext): add useContext hook for simpler use (#1125) --- client/src/Providers/ToastContext.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/Providers/ToastContext.tsx b/client/src/Providers/ToastContext.tsx index 88229f9c0..10ae884da 100644 --- a/client/src/Providers/ToastContext.tsx +++ b/client/src/Providers/ToastContext.tsx @@ -1,4 +1,4 @@ -import { createContext } from 'react'; +import { createContext, useContext } from 'react'; import type { TShowToast } from '~/common'; import { useToast } from '~/hooks'; @@ -10,6 +10,10 @@ export const ToastContext = createContext({ showToast: () => ({}), }); +export function useToastContext() { + return useContext(ToastContext); +} + export default function ToastProvider({ children }) { const { showToast } = useToast();