ilokesto

Mount

Mount renders direct children immediately. If children is a function, it calls the function after mount and renders fallback until the result is resolved.

import { Mount } from '@ilokesto/utilinent';

<Mount fallback={<p>Preparing preview...</p>}>
  {async () => <Preview data={await loadPreview()} />}
</Mount>

Props

PropTypeDescription
childrenReactNode; () => ReactNode; Promise<ReactNode>Direct node or node-producing function.
fallbackReactNodeRendered while a function child is pending or after an error.
onError(error) => voidCalled when the child function throws or rejects.

Tag form

<Mount.div fallback={<Spinner />} className="preview">
  {() => <Preview />}
</Mount.div>

Race safety

Mount tracks calls and ignores stale async results after cleanup or a newer call. Keep the children and onError functions stable when possible so work is not restarted unnecessarily.

On this page