Do not use or you will be fired. I found that amusing. I don't know what that says about whether that's going to change in the future, but yeah, let's have a look at what that perform work was doing. So yeah, it's a reference to retry segment, which tries to render that element.
So if we have a look at this, this retry segment is responsible for resolving elements that are from the past segment, and a lot of the work happens in attempt resolve element. And this basically is attempting to translate the element into an array that we can serialize and send back as JSON. It can deal with HTML, it can deal with fragments, it can deal with server components, client components, react demos, but the net result here is it turns this React element into some sort of tuple with like the symbol, the element, its key and its props. And once it has been reduced to this format, it can be processed as a model chunk by process model chunk.
So let's jump to that. So basically we're given here the model and it's turned into a string and serialized. So if I just let the debugger run through, we might have a look at the format of the content here. So let's open this up. So as we can see here, it starts with the type of the element here. We've got the element name itself and then we've got the element's props and then one of those props is children, and then it repeats itself. So this is effectively the serialized representation of the element tree. And we've got some special nomenclature in here that the client can understand to work out what sort of element we're dealing with here. Let's have a little bit of a look at how this resolve model to JSON works, which is what generates this JSON. Basically, anything that's already been converted into that tuple format we talked about seems to be sent as is, but everything else is converted into a similar format. It seems that it has guards around things that can't serialize the JSON, so it can't serialize classes, it can serialize just plain old JavaScript objects, it can't serialize functions, event handlers, all the things that don't make sense represented as a string. If we run this through again until we get to where it's rendering the sidebar list, where we've got multiple components, we can see here the UL. This is rendering the sidebar note list, so we might just open up that note list component and have a look at what it's made up of.
As we saw before, it's got a sidebar note inside it, but if we have a look in the sidebar note itself, it in turn renders a client sidebar note. So if we have a look at the client sidebar note, we can see it has properties like ID, title, et cetera. If we look back at this JSON that's being output, we can see in here that there's a lot of these at five references. So previously, we were looking at a JSON, we could see in there, there was like div, et cetera, things that we could rationalize down to HTML elements. But now we're seeing this at five and we can see the ID and the title properties that match up with these properties over here, as well as the expanded children. And so these at fives placeholders in the JSON that's sent back, and the client will then replace these slots with the client side elements. So wrapping things up on the server side, the only thing left is that start flowing, which we had before for the drain handler. If I jump back to that. So this createDrainHandler here, it's a wrap around start flowing, and what start flowing does is flush the completed chunks.
Comments