feat(useToastContext): add useContext hook for simpler use (#1125)

This commit is contained in:
Danny Avila 2023-10-30 10:00:20 -04:00 committed by GitHub
parent 8f328ec6a3
commit 9f5d77eeb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<ToastContextType>({
showToast: () => ({}),
});
export function useToastContext() {
return useContext(ToastContext);
}
export default function ToastProvider({ children }) {
const { showToast } = useToast();