/ src / components / AsyncText.jsx
AsyncText.jsx
 1  import { useEffect, useState } from 'preact/hooks';
 2  
 3  function AsyncText({ children }) {
 4    if (typeof children === 'string') return children;
 5    const [text, setText] = useState('');
 6    useEffect(() => {
 7      Promise.resolve(children).then(setText);
 8    }, [children]);
 9    return text;
10  }
11  
12  export default AsyncText;