// // Copyright 2023 DXOS.org // import React, { captureOwnerStack, useEffect, useState } from 'react'; import { mx } from '@dxos/ui-theme'; import { safeStringify } from '@dxos/util'; import { ErrorStack, parseCaptureOwnerStack } from '../components'; export type LoadingProps = { data?: any }; /** * Storybook loading component. */ export const Loading = ({ data }: LoadingProps) => { const [visible, setVisible] = useState(false); const ownerFrames = parseCaptureOwnerStack(captureOwnerStack()); useEffect(() => { const t = setTimeout(() => setVisible(true), 500); return () => clearTimeout(t); }, []); return (

Loading State

{safeStringify(data, undefined, 2)}

Owner stack

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

No owner stack (production build or unsupported context).

)}
); };