Lazy rendering for asynchronous React components.
import LazyFactory from '@jeswr/react-lazy-renderer'
const LazyTextDisplay = LazyFactory<{ text: Promise<string> | string }>(
async ({ text }) => {
const resolvedText = `${await text}`;
return <>{resolvedText}</>;
},
);
function App() {
return <LazyTextDisplay text={Promise.resolve('Foo')} />;
}
©2021–present Jesse Wright, MIT License.