From the course: React: Software Architecture

Unlock the full course today

Join today to access over 24,300 courses taught by industry experts.

Route-based code splitting

Route-based code splitting

- Okay. So now that we've seen some very basic code splitting, what we're going to do is take a look at a somewhat more common usage of code splitting, which is to split our code based on routes. So previously, we had these one, two, and three components that were displayed on our about page and we saw that when we navigated to the about page, only then did we actually load the code for those components. Now, that's one way of doing code splitting. But again, what we can do is actually split our code based on the different routes. So in other words, we won't have to actually load the code for any of the pages, right? Our homepage, our about page, or our articles page until the user actually goes to that page. So let's take a look at how to do that. The first thing we're going to do is go into our pages folder and open up our about, articles, and home pages. And we're going to need to export these as the default…

Contents