Getting ready

When you import a module, it's a static thing, and the code for the desired module gets included in the general source code pack. However, you can work with dynamic import() calls to load code at runtime. You could work with that by yourself, but there's already a simple package you can import, react-loadable, that will take care of most situations. Let's install it in the usual way:

npm install react-loadable --save

We will be using a few of all the features of this package, so you should take a look at https://github.com/jamiebuilds/react-loadable to get ideas about more ways to enhance your dynamic code loading features.

As of December 2018, import() is at stage 3, meaning that it's a candidate for acceptance, expecting only few a (if any) changes and is well on its way to stage 4, which means that it will be included in the formal ECMAScript standard. However, as with other JS extensions, you can already use them in your code, and it's supported by Babel and Webpack. You can read more about import() at https://tc39.github.io/proposal-dynamic-import/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.86.183