-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[WIP] Replay load/error events that happen earlier than commit #13862
Conversation
If we create an img/image/link those might fire their load event before we commit. If that happens, we need to store the event so that we can replay it during the commit phase.
Is it not possible to receive more than one event before mount? |
ReactDOM: size: 🔺+0.6%, gzip: 🔺+0.3% Details of bundled changes.Comparing: 21a79a1...33a2d73 react-dom
scheduler
Generated by 🚫 dangerJS |
@sophiebits No, because you can't change the src. At least not without resuming of host nodes which we don't have yet. If there's only one resource, it either loads or errors. This PR replays these events even after mount which is a bug though. |
The timing of these events are a bit weird. I guess they will fire in the "layout" phase. So it'll fire before componentDidMount of the parent that rendered it. It's also before the ref on the image has fired so you don't even have a ref on it yet. This is consistent with onFocus/Blur events of auto-focused elements. It's a bit weird that it is so late but not fully after initialization. However, it is good because it means you can setState at this point. setState before commit gets sketchy. |
Does audio/video/script/source also need this? |
</ConcurrentMode>, | ||
); | ||
|
||
// someHowGetAnImage.dispatchEvent(loadEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trueadm I think we’ll need to spy on document.createElement by wrapping it so we can detect which img instance React creates.
We can’t use a ref to simulate this because it doesn’t resolve in time.
Hi @sebmarkbage! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
This was fixed in #23316. |
If we create an img/image/link those might fire their load event before we commit. If that happens, we need to store the event so that we can replay it during the commit phase.
I had an idea to fix it but this is still WIP because I actually need to test if this approach works.