-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Fix ReferenceError when requestAnimationFrame isn't defined #13152
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
Conversation
const localCancelAnimationFrame = | ||
typeof cancelAnimationFrame === 'function' | ||
? cancelAnimationFrame | ||
: (undefined: any); |
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.
This module throws if this is undefined, right? Maybe we should use an invariant?
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.
Didn't want to spend the bytes.
I think it actually used an invariant in the past, and Sebastian wanted to relax that to a warning.
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.
I guess in sync mode this module is never used so an invariant would be harsh
ReactDOM: size: 🔺+0.1%, gzip: 0.0% Details of bundled changes.Comparing: 88d7ed8...9064cf5 react-dom
react-art
react-scheduler
Generated by 🚫 dangerJS |
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.
I think this makes sense, thanks for fixing. Also thinking we may want to throw if the scheduler
starts to try and run and rAF is still undefined. Will consider that for the future.
Nice! thanks for the fix :) Edit Confirmed that this fixes the regression in the open source project I first noticed it in. |
Fixes #12980 (comment).
We can't access a global if it's not defined so we should always guard it. I consolidated these reads in one place. I also changed the test to reproduce the problem on master.