-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer doRender until after value of prevRender is taken #70
Conversation
Good catch. Thank you for sending this. This just highlights, for me, how much I need to write tests for all standard functionality.
It's possible I don't clearly understand the problem you're describing, but I think that currently this situation would not make a difference because of |
(I'm going to merge because I absolutely think this fix is right, and want it in master ASAP. Let's continue to discuss here or in a new issue if you think it needs more visibility 😄 ) |
Hey I think this was actually caused by a bug in my code. I was passing in a component to the view constructor and storing it in the view... So the constructor for the child component wasn't being called on the parent Render... A bit like this:
This is wrong. The constructor for the I'm pretty sure this is the only reason that However, this PR won't break anything, so it should be safe to leave merged for now. |
Oh wow. I sat here for maybe ~20 mins trying to read over your last comment and understand the situation at play here. Couldn't make any sense of how this change could be wrong. I see now that I severely misunderstood this change. I should've read more into I'm going to think more about this, just to make sure I'm not doubly confused, but I think that if any new render is equal to the prev render, we should perhaps panic as that is quite the invalid state to be in. Hmm.. we should probably revert as well |
Yes, it should be impossible, so I think I agree with your panic idea... It certainly would have made my debugging quicker... |
@davelondon Very late with following up on this, but I've just reverted this change + added in the panic. Let me know if you have other thoughts on this / can confirm it looks correct! |
Hey @slimsag one more bug... if h.children[i] == prev.children[i], then doRender will reset the prevRender of prevChild, and prevRender.Node will be nil.
This fixes it by deferring doRender until after we've taken the value of prevRender.
However, this worries me... What happens if the list order is mixed up and doRender clears the prevRender.Node of a component somewhere later in the prev children... Perhaps we need to read the prevRender values from all the children before doing any doRenders? I'll try to set up this situation to double check it's an issue.