Hey everyone! So today, I'm actually going to be discussing how we can take UX to the next level with React Suspense and Concurrent mode. So before starting, for the ones who don't know me, hey, I'm Nikhil, I'm a software engineer at Postman. I actually handle stuff around design systems, Postman on the web, and Postman as a platform. You can actually find me on Twitter, on Github. I actually love to talk about design systems, and performance in general, so come say hi, it's actually going to be a great chat.
So before diving in, let's cover what are going to be the key takeaways of this lightning So in this talk, we are actually going to discuss how we can actually have more control over the loading area, which means how we can actually control where exactly do we want to show a loading shape. Is it going to be the whole page, or can we actually control loading on the UI that's going to be asynchronous with the API called Suspense? Secondly, we are going to see how we can start prefetching our data or our screens in background while we are right now in some other screen with the magic of concurrent mode. And thirdly, we'll actually see how we can actually reduce that janky spinner Nudra experience with actually the users for our faster connections actually face with a loading indicator which just comes and goes in a flash for them using a hook called use transition. Okay, so with that being said, let's actually deep dive and thread this road to a great UX together.
So I'll actually switch to a small demo of a Twitter dashboard that I actually have here, right? So this dashboard actually shows me a profile section where it shows my name, my designation, it has a small about me section, which actually displays a small description around me and the work that I've done. And there's a tweet section which actually just shows what is that then treat that I put it. Just don't try to go check the Twitter. It's just something that I couldn't write. So and there's an extra button, which I click and then I just see another tweet. Okay, so far, so good. Now, let me actually just go and switch to concurrent mode on version of this app. And they just see how we can actually improve the UX right now. So let me just refresh and I go to this about me section. And if you see I have this nice big loader on my whole tab. And because of like, even if I have just small content inside my tab, which is my description, which was like asynchronous, but I'm actually loading my whole tab, and I'm actually showing a screen up for this whole section, which is actually not a great user experience. Right? I could actually rendered my static content as regardless of the fact that my description is running or not right. So moving on to how it is right now coded, let's actually see how we are actually written this up in our code. So we have a suspense block inside this block, I have some static content as a small div. So what if I could actually take this particular div out and render this inside, outside the suspense block, right? And this is actually how suspense actually gives you a fine grain control by defining a small sort of a boundary, and it lets you control over what exactly do you want to show your loading upon. So let's say this, I refresh this app, I go to my about me section, and now my static content is already there for my users to interact with while my description was loading. Okay, so, so far so good and it's simple. Now, let's actually try to uncover and see how concurrent mode can actually help us in removing some of those more loaders, right? So on the left side, we actually have a synchronous synchronous mode of that app. And we actually, right now, fetch stuff while we are going to a screen, right? So in the left, and I click on this about me section, I see a nice loader, and then I start loading that stuff right. And, but since concurrent mode is something which switches tasks or into priority, I can actually start fetching my description and my tweets, actually, when I am right now on the profile page, and I can actually start rendering things in parallel, while I'm on this profile. So what do you think that what would happen if I just go to about me section and I just click on this, would I see a loader? Let's actually find out.
Comments