Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function lazyWithPreload(factory) {
const Component = React.lazy(factory);
Component.preload = factory;
return Component;
const StockChart = lazyWithPreload(() => import("./StockChart"));
// somewhere in your component
handleYouMayNeedToRenderStockChartSoonEvent() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment