Organize Your Code with Modules
Some web applications consist of a single JavaScript application that manages the whole page. In that case, it can make sense to include React in the application bundle. That way the browser does not make separate requests for React and ReactDOM. And since no other code uses React, there isn’t the problem of downloading React twice. It’s also a bit simpler to deploy since everything is included in one file, and you don’t need to update the HTML source to include the correct React version. Finally, importing React as a module is the most flexible method: in Chapter 6, Work Well with Others, we’ll see that we can use an external React even if we import it as a module! So, to get started with modules, let’s download ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access