import { useActor } from '@xstate/react'; import './App.css'; import { notificationsMachine } from './notificationsMachine'; import { ToastKind } from './toastMachine'; import { Toast } from './Toast'; import { createInspector } from '@statelyai/sdk'; const inspector = createInspector(); const messages: Record = { info: 'Sync finished.', success: 'Invite sent.', error: 'Upload failed. Try again.' }; function App() { const [state, send] = useActor(notificationsMachine, { inspect: inspector.inspect }); const { visible, queue } = state.context; return (

Toast queue

At most three toasts are shown at once; the rest wait in the parent's queue. Hover a toast to pause its timer.

{(Object.keys(messages) as ToastKind[]).map((kind) => ( ))}

visible: {visible.length} ยท queued: {queue.length}

{visible.map((toastRef) => ( ))}
); } export default App;