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 ...
Get React for Real now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.