Current section: Windowing 33 exercises
Problem

Virtualizer

Loading exercise

Transcript

00:00 Let's take a profile of what things look like now. We're at a 6x slowdown. We're going to record And I'm just going to do one state change that and then take it off and take a look at this What the devil I thought we just optimized this this is supposed to be memoized and so everything's supposed to be super fast and everything

00:16 Well turns out that just checking whether an element needs to be re-rendered can Be a death by a thousand cuts because we no longer are Just rendering a couple or 500 of these we are now rendering all of these cities

00:34 Which is an outrageous amount of cities and so react even just in checking Do you need to re-render? Do you need to re-render? Do you need to render all of that? Takes a really long time and then the the browser updating and handling all those dom nodes also is going to be problematic

00:49 so like you can take a look at this and run the profiling right there and You'll notice I don't know why that's looking funny like that, but You'll notice we are only re-rendering one thing and that's taking less than 0.1 milliseconds This is taking a hundred and thirty seven milliseconds

01:11 Yikes, that is a lot of milliseconds for this component and it's again because the There are just so many elements that it needs to check or do you need to re-render? So what we are going to do is virtualize this list so that you don't have to render so many items We're going to be using tansec virtual. I think you're going to enjoy this. Let's get into it