import React, { type FC, type PropsWithChildren } from 'react'; import { usePromise } from '@wener/reaction'; import { NonIdealState } from '../../daisy'; import { resolveErrorMessage } from '../../toast'; import { LoadingIndicator } from '../components'; import { getUserStore } from '../context'; import type { UserProfileData } from '../store/UserStore'; export const UserLoader: FC< PropsWithChildren & { load?: () => Promise; } > = ({ children, load }) => { const { loading, error } = usePromise(async () => { if (!load) return; let data = await load(); data && getUserStore().getState().load(data); }, []); if (loading) { return ; } if (error) { return ; } return children; };