Hi Nathan! Thanks for your interest! Perhaps it's me, but I'm not quite sure what you mean : )
By "observable object", do you mean the object wrapped with the store function?
Because currentlyRenderedComponent is a global variable, this can occur :
Then, when the observable object is modified, the parent component is not rendered again. A fix for that is replacing currentlyRenderedComponent by a stack in which we push a component when it starts rendering and we pop it when it's done.
Sorry for the late reply! I understand what you mean now, but as far as I understand react, this is not exactly correct :)
React does not render the tree of components "top-to-bottom" so to speak, but rather creates a virtual-dom data structure which is then rendered to the screen. React contains a "scheduler" which decides when to do the actual rendering.
So, the cycle that you described, would rather look more like:
currentlyRenderedComponent = parent component
currentlyRenderedComponent === undefined
currentlyRenderedComponent = child component
Dan Abramov (from the react team) has written a blog post about the react rendering model, which I think describes what I'm trying to say in more depth and perhaps more eloquently :)
Here's the section that is relevant to your question: overreacted.io/react-as-a-ui-runti...
Thank you for your explanations, that is the part I was missing and it's very clear now :)
you're very welcome! 👌
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.