UNPKG

@dark-engine/core

Version:

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)

23 lines (22 loc) 763 B
import { __useCursor as useCursor } from '../internal'; import { useUpdate } from '../use-update'; import { component } from '../component'; import { Fragment } from '../fragment'; import { Shadow } from '../shadow'; const Suspense = component( ({ fallback = null, slot }) => { const cursor = useCursor(); const update = useUpdate(); const isPending = cursor.hook.getIsPending(); const content = [ isPending ? Fragment({ key: 1, slot: fallback }) : null, Shadow({ key: 2, isOpen: !isPending, slot }), ].filter(Boolean); cursor.hook.setIsSuspense(true); cursor.hook.setUpdate(update); return Fragment({ slot: content }); }, { displayName: 'Suspense' }, ); export { Suspense }; //# sourceMappingURL=suspense.js.map