import { Meta, ReactRenderer } from "@storybook/react-vite"; import { PartialStoryFn } from "storybook/internal/types"; import { useRef } from "react"; import { NotificationsProvider } from "./NotificationsProvider"; import { useFetch } from "./useFetch"; import { Button } from "../button/Button"; import { useContextNotifications } from "./useContextNotifications"; const meta = { title: "Components/NotificationsProviderLegacy", component: NotificationsProvider, decorators: [ (Story) => ( ), ] as ((story: PartialStoryFn) => React.JSX.Element)[], } satisfies Meta; export default meta; export const Context = () => { const counter = useRef(0); const { addNotification, notifyError } = useContextNotifications(); const fetch = useFetch(); function handleClick() { counter.current += 1; addNotification(`Notification num. ${counter.current}`, { expiration: 5000, }); } function throwError() { try { throw new Error("Custom error message"); } catch (e) { notifyError(e); } } function handle404Error() { fetch("/throw-404-error"); } return (
link
); };