Fix ReferenceError when requestAnimationFrame isn't defined#13152
Fix ReferenceError when requestAnimationFrame isn't defined#13152gaearon merged 2 commits intofacebook:masterfrom
Conversation
| const localCancelAnimationFrame = | ||
| typeof cancelAnimationFrame === 'function' | ||
| ? cancelAnimationFrame | ||
| : (undefined: any); |
There was a problem hiding this comment.
This module throws if this is undefined, right? Maybe we should use an invariant?
There was a problem hiding this comment.
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.
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 |
flarnie
left a comment
There was a problem hiding this comment.
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.