mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-23 19:00:15 +03:00
12 lines
308 B
JavaScript
12 lines
308 B
JavaScript
import { useEffect, useState } from 'preact/hooks';
|
|
|
|
function AsyncText({ children }) {
|
|
if (typeof children === 'string') return children;
|
|
const [text, setText] = useState('');
|
|
useEffect(() => {
|
|
Promise.resolve(children).then(setText);
|
|
}, [children]);
|
|
return text;
|
|
}
|
|
|
|
export default AsyncText;
|