Intermediate React, v2 Intermediate React, v2

Code Splitting Review and Q&A

Check out a free preview of the full Intermediate React, v2 course:
The "Code Splitting Review and Q&A" Lesson is part of the full, Intermediate React, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Students ask questions about the Suspense module, and using code splitting with Parcel vs Webpack. Brian wraps up the section, and resets the code for the next segment of the course.

Get Unlimited Access Now

Transcript from the "Code Splitting Review and Q&A" Lesson

[00:00:00]
>> Speaker 2: Does it just bubble up to the nearest suspense?
>> Brian Holt: Mm-hm, so if you had one above that, it would hit the first closest one, yeah.
>> Brian Holt: And I think it just crashes if you don't have one, I'm not sure.
>> Brian Holt: So Facebook says that they're using suspense everywhere.

[00:00:22] Yeah.
>> Speaker 3: Is there anything different about using this with Parcel versus Webpack?
>> Brian Holt: Nope, they work the same way. Yeah, so they both look for this import keyword,
>> Brian Holt: And they'll split intelligently on that point and they both know how to do it. Maybe mechanically it works a little bit differently, but lazy comes from React and so lazy knows how to handle it.

[00:00:51]
>> Brian Holt: Same with rollup as well. So that's code splitting. There's not a lot more to it than that. It's a fairly easy technique, especially with lazy now, lazy and suspense. If you watch V1 and V2 of this course, this used to be a lot more difficult to do.

[00:01:06] [LAUGH] And it's just getting easier, which is cool.
>> Brian Holt: Okay, so that's the end of code splitting. So I'm gonna go reset my repo really quick.
>> Brian Holt: I'll do that in here, rather.
>> Brian Holt: So I'm gonna say git reset HEAD --hard, and then I'm gonna say git clean -f.

[00:01:38] And then I'm gonna say npm install. Again, if you want to check that out, the branch of that that's available is called code splitting and it is on the GitHub repo.