Summary
This chapter was all about code splitting and bundling, which are important concepts for large React applications. We started by looking at how code is split into bundles in your React applications by using the import()
function. Then, we looked at the lazy()
React API and how it helps to simplify loading bundles when components are rendered for the first time. Next, we looked more deeply at the Suspense
component, which is used to manage content while component bundles are being fetched. The fallback
property is how we specify the content to be shown while bundles are being loaded. You typically don’t need more than one Suspense
component in your app, as long as you follow a consistent pattern for bundling pages of your app.
In the next chapter, you’ll learn how to use the Next.js framework to handle rendering React components on the server. The Next.js framework allows you to create pages that act as React components and can be rendered on the server and...