In your Root
react component, you have to add NotificationProvider
:
const Root: FC = () => {
const router = useMemo(() => getRouter(), []);
return (
<NotificationProvider>
<AuthProvider>
<ModalProvider>
<RouterProvider router={router} />
</ModalProvider>
</AuthProvider>
</NotificationProvider>
);
};
Then in your components, you can use the hook useNotifications
;
export const MyComponent: FC<unknown> = () => {
const { notify } = useNotifications();
return (
<button title="Click me" onClick={()=> {
notify({ type: 'success', title: "Hello", text: `I'm a toast example` });
}}>
Click me
</button>
);
}