react-dom development bundle uses Array.from

Created on 4 Apr 2018  路  15Comments  路  Source: facebook/react

Do you want to request a feature or report a bug?

Bug (?)

What is the current behavior?

Currently, the 16.3.x versions of react-dom ship react-dom.development.js containing usage of Array.from which is not available in certain React-supported browsers like IE11. It causes breakage if those particular code paths are taken in such a browser (I ran into it using <StrictMode> in IE11).

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

Reproduction (should see "Hello, world!" but IE11 will crash and show nothing):
https://codepen.io/anon/pen/zWJBrO?editors=0010

What is the expected behavior?

react-dom.development.js would not use Array.from or document that a polyfill is required.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

react and react-dom: 16.3.0-alpha.0 through 16.3.1
Internet Explorer 11

Bug Regression

Most helpful comment

Agree! This one is DEV-only. Maybe we can require full ES6 env with 17.

All 15 comments

Thanks for the report @wKovacs64, sorry about the unexpected breakage.

@gaearon what do you want to do here, stop using Array.from or ask that users polyfill it? It's currently being used by ReactStrictModeWarnings to convert a Set in a few places like:

https://github.com/facebook/react/blob/1c2876d5b558b8591feb335d8d7204bc46f7da8a/packages/react-reconciler/src/ReactStrictModeWarnings.js#L72
This case would be easy enough to refactor without Array.from

We definitely should not have been using Array.from there. 馃槥

Sorry 'bout that folks~

thanks

Why shouldn't we have been using Array.from?

No IE support.

We used to run in IE11 with Map/Set/rAF polyfills so IMO adding dependencies on other builtins is a breaking change. We didn't ask people to polyfill the whole ES6 environment, just these three things.

OK. Maybe in the future. We shouldn't get in the habit of inlining implementations of ES6 builtins if we can avoid it because it bloats bundle size and is also less maintainable.

Agree! This one is DEV-only. Maybe we can require full ES6 env with 17.

Sounds good! :+1:

@gaearon you mean, new implementations from 17 should be accepting ES6?

I'm saying that in React 17 we can bump the runtime requirement to assume ES6 environment.

Uhm... gotcha. I was just concerned about many applications (from DoD) using React that still runs under IE11 that isn't compatible with many ES6 functions.

If we bump minimal requirement to ES6 this will only require polyfilling some functions. It doesn't necessarily mean dropping IE support.

Thanks all.

Was this page helpful?
0 / 5 - 0 ratings