Skip to content

Instantly share code, notes, and snippets.

Embed
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() {
StockChart.preload();
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment