Last active
April 20, 2020 19:41
-
-
Save pomber/0cb1aa7cfb7863b9411390156d97afcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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