mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-24 03:08:13 +03:00
13 lines
308 B
React
13 lines
308 B
React
|
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;
|