Fix react-dom ReferenceError requestAnimationFrame in non-browser env (#13000)#13001
Merged
gaearon merged 3 commits intofacebook:masterfrom Jun 8, 2018
Merged
Conversation
…facebook#13000) The facebook#12931 ( facebook@79a740c ) broke the server-side rendering: in the `fixtures/ssr` the following error appeared from the server-side when `localhost:3000` is requested: ``` ReferenceError: requestAnimationFrame is not defined at /__CENSORED__/react/build/node_modules/react-dom/cjs/react-dom.development.js:5232:34 at Object.<anonymous> (/__CENSORED__/react/build/node_modules/react-dom/cjs/react-dom.development.js:17632:5) at Module._compile (module.js:624:30) at Module._extensions..js (module.js:635:10) at Object.require.extensions.(anonymous function) [as .js] (/__CENSORED__/react/fixtures/ssr/node_modules/babel-register/lib/node.js:152:7) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Module.require (module.js:568:17) at require (internal/module.js:11:18) ``` The exception pointed to this line: ```js // We capture a local reference to any global, in case it gets polyfilled after // this module is initially evaluated. // We want to be using a consistent implementation. const localRequestAnimationFrame = requestAnimationFrame; ``` **Test plan** 1. In `react` repo root, `yarn && yarn build`. 2. In `fixtures/ssr`, `yarn && yarn start`, 3. In browser, go to `http://localhost:3000`. 4. Observe the fixture page, not the exception message.
This was referenced Jun 8, 2018
Collaborator
|
Please run I think it would make sense to remove the warning call from Then at the callsite you probably want to fire that warning if it doesn't exist, and substitute it by a shim in that case (e.g. that throws on call). |
…facebook#13000) According to the comment by @gaearon: facebook#13001 (comment)
|
ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1% Details of bundled changes.Comparing: d3e0a3a...aa90798 react-dom
react-art
react-scheduler
Generated by 🚫 dangerJS |
gaearon
reviewed
Jun 8, 2018
| typeof requestAnimationFrameForReact === 'function' | ||
| ? requestAnimationFrameForReact | ||
| : function(callback: Function) { | ||
| throw new Error( |
Collaborator
There was a problem hiding this comment.
Please use invariant(false, message) here so the error message gets stripped out in prod.
gaearon
reviewed
Jun 8, 2018
| ? requestAnimationFrameForReact | ||
| : function(callback: Function) { | ||
| throw new Error( | ||
| 'React depends on requestAnimationFrame, but this shim was called.', |
Collaborator
There was a problem hiding this comment.
Let's change the message to the same one as in the warning above.
…acebook#13000) According to the comment by @gaearon: facebook#13001 (comment)
gaearon
approved these changes
Jun 8, 2018
Collaborator
|
Thx |
Contributor
|
Thanks for fixing this! :) |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The #12931 ( 79a740c ) broke the server-side rendering: in the
fixtures/ssrthe following error appeared from the server-side whenlocalhost:3000is requested:The exception pointed to this line:
Test plan
reactrepo root,yarn && yarn build.fixtures/ssr,yarn && yarn start,http://localhost:3000.