feat(useToastContext): add useContext hook for simpler use (#1125)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user