That's a whole separate talk again. But this is yet another example of React shipping invisible performance improvements under our noses without anyone noticing. So, use effect, batching, suspense, all those are examples of React's invisible hand that made our apps faster. There are quite a few more examples that I wanted to talk about, some successful, some not. Sadly, they didn't fit in. I know React gets quite a lot of burn, sometimes deserved, but this invisible hand is honestly something I really, really like.
Thank you! Let's get into the Q&A. You can still ask questions with the code 0614. I'm excited to see what people are asking. The suspense is killing me!
All right. Does use layout effect have the same situation as did mount did update? Yes. Use layout effect has the same behaviour as company did mount, company did update, and this is the reason React discourages you from using it, because, if you use it, you have a risk of reintroducing the same performance issues that company did mount had. Guys, shhh in the back, thank you! Thank you.
What is the cost of adding suspences? What if I add 100 of them on a page? I asked the same question. I asked Dan Abramov about this, like, hey, what happens, like, why can't I go and wrap every single element on the page with suspense? Is there a new drawback to this? The answer that I received was that there's basically no significant drawbacks. The only issue that you will have is that if anything suspends, actually suspends because it is fetching something, then, like, you will see the fallback rendered. If you forget to provide a fallback somewhere, that's going to be, well, the element would flash, the element would disappear. But apart from that, I'm not really aware of major drawbacks. Thank you.
There's a couple of questions around selective hydration. Can I choose what to hydrate first, like in the Airbnb example, and does it only happen on click, and can you tell us more about that? Great question. So the first, can you select what to hydrate first? As far as I know, Rack just hydrates all the suspense boundaries from top to bottom. There's probably some, like, data fetching or, like, waiting for server data part involved, but there's no API I'm aware of that would let you tell, like, hydrate this first. So, not only on click forces it, what forces hydration is all the events that Rack calls discrete which are basically on click, on input, and I think that's it. So stuff like mouse moves or scrolling that shouldn't force hydration. Thank you.
You seem to be very in the weeds of the React perf ins and outs. Someone asks... Not by choice.
Comments