// // Copyright 2023 DXOS.org // import React, { captureOwnerStack, useEffect, useState } from 'react'; import { mx } from '@dxos/ui-theme'; import { safeStringify } from '@dxos/util'; import { ErrorStack } from '../components/ErrorFallback/ErrorFallback.tsx'; import { parseCaptureOwnerStack } from '../components/ErrorFallback/parse-stack.ts'; export type LoadingProps = { data?: any }; /** * Storybook loading component. */ export const Loading = ({ data }: LoadingProps) => { const [visible, setVisible] = useState(false); // React exports `captureOwnerStack` only from its development build; a production Storybook has none. const ownerFrames = parseCaptureOwnerStack(typeof captureOwnerStack === 'function' ? captureOwnerStack() : null); useEffect(() => { const t = setTimeout(() => setVisible(true), 1000); return () => clearTimeout(t); }, []); return (

Loading State

{safeStringify(data, undefined, 2)}

Owner stack

{ownerFrames && ownerFrames.length > 0 ? ( ) : (

No owner stack (production build or unsupported context).

)}
); };