react: React app not rendering in IE11 and below
Do you want to request a feature or report a bug? BUG
What is the current behavior? App doesn’t render in IE11 and below.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).
- Build React app with Webpack
- Launch IE11 or below (not an emulator)
- You will see a blank screen or half-compiled React app with the following error:

What is the expected behavior?
- To render as it does in Chrome, Firefox, etc.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
We’ve temporarily shrink-wrapped our dependencies so that we can continue to serve our app. We’re starting to believe that it’s coming from a dependency that react, apollo or webpack may be relying on…
Shrink-wrapped versions of our dependencies (left is the new one that’s broken and the right one is the old one that continues to work across all browsers) https://www.diffchecker.com/SyaJUcsk
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 22
- Comments: 49 (6 by maintainers)
Links to this issue
Commits related to this issue
- Move polyfill from `import` to `webpack` This fixes an issue in IE11. See https://github.com/facebook/react/issues/8379#issuecomment-264934168 for more details. — committed to chriddyp/webpack-react-redux by chriddyp 7 years ago
- Enforce loading babel-polyfill first This is to avoid loading anything before loading the polyfill, otherwise we risk loading dependencies (such as React) before it. This was causing the compatibili... — committed to element-hq/element-web by lukebarnard1 6 years ago
- Ensure compatibility with Internet Explorer We need to include babel-polyfill in our application as older versions of Internet Explorer are not capable of the latest EcmaScript features and functiona... — committed to DBCDK/merkur by jbndbc 6 years ago
This bit me too after upgrading to React 15.4 and I had to spend some time figuring it out. So I’m posting this to help others in the same situation.
If you are using react-hot-loader v3 for hot-reloading in DEV environment you need to load
react-hot-loader/patchafterbabel-polyfilldoes. So Webpack’sentryfield should look like the following to work correctly with react 15.4.x, react-hot-loader v3 and webpack-dev-server:Hope this helps 😉
Thank you to everyone on this thread, esp. @gaearon and @damonbauer. In case this helps someone else, here are the changes I ended up making:
I fixed this by enforcing a load order in my webpack bundle:
Thanks for your patience and your infinite wisdom 😉 @gaearon
Nothing worked for me either, changing the order of the polyfill or anything else. What worked for me is adding this JS link in the index.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js"></script>After adding this I was successfully able to run the react app in IE 11
The problem is that React doesn’t “recognize” its own element. This likely happens because of the failed
$$typeofcheck. Somehowreactandreact-domno longer “agree” on the$$typeofvalue which should betypeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103.This might mean that
reactandreact-domsomehow get different results when testing forSymbolpolyfill. For example if you load a polyfill afterreactinitializes but beforereact-domdoes, you might get this issue.To debug it further I recommend finding this fragment in your bundle:
You should see it two times (once from
reactand once fromreact-dom):Try adding logs of
rvalue and see if they’re different. If they are, you’d need to figure out whyreactandreact-domget different values when checking for existence ofSymbol.The reason this is new in 15.4.0 is because there only used to be one version of this code, but now it’s in both packages (intentionally).
I was able to get this working by just including the
'core-js/modules/es6.symbol'BEFORE'react'.'core-js/modules/es6.symbol'is much smaller than'babel-polyfill'so others may want to consider trying this as well@qborreda The solution is to load
babel-polyfillbeforereactandreact-dom.For Webpack users this means making the main entry an array and the first element of the array is gonna be
babel-polyfill, as shown here: https://github.com/catamphetamine/webpack-react-redux-isomorphic-render-example/blob/4d6208662157cfc6bac115fe5dff956c4976145c/client/webpack/webpack.config.js#L23In case somebody else comes across this, I was using the commons chunk plugin which was loading react in before the poly. To get around this I ended up with:
Not sure if that is the ‘right’ way but it is the only way with commons I found that worked.
I tried all of the above and none of it worked except for a tweak on @jkilesc 's work. So the order of imports matter.
You would think your entry script having the polyfills at the top would be different than including it as a separate file in your entry array like babel-polyfill? No.
So from
to
Why? During the transpile the order of libraries seems to shift so that the polyfill is loaded after React? But there you go. This also worked where babel-polyfill on my entry script did not.
This just started happening to me again in the last week in IE11 (ive resolved this same bug in the past using the above suggestions).
The error:
I did, @gaearon. It didn’t make sense why it would work in Chrome and Firefox but not in IE11 and below. Thoughts?
For those who has the error, but nothing above worked: I’ve had same exact error, but the cause was completely different. There was code where react components were shared between iframes, but components to have different $$typeof value in different iframes, which caused the error. Although this worked with other browsers, IE11 had the error.
@FarhadG I hit this on my current project and had to include the Symbol polyfill. I do this by adding a
polyfills.jsto my entry point that looks like:Edit: We use the
babel-preset-react-optimizepackageMaybe you enabled
babel-plugin-react-inline-elements. It requires a Symbol polyfill and won’t work without it. See https://github.com/facebook/react/issues/5138.This is a
react-hot-loaderissue because I only have it in dev mode and I’m not having it in production mode. Addingbabel-polyfillbeforereact-hot-loader/patchfixes this bug.Hi,
@gaearon, here’s my investigation in order to answer https://github.com/facebook/react/issues/8379#issuecomment-263962787
Facing the same issue I tried to see why React.isValidElement was not recognizing some react elements. Looking through react and react-dom code, I thought that there was no reason why react and react-dom would not agree on what
REACT_ELEMENT_TYPEwas, unless you require the polyfill between requiring react and react-dom for the first time. But importing them together should not cause a problem.Indeed, https://github.com/facebook/react/blob/v15.4.2/src/shared/utils/ReactElementSymbol.js#L17 is declared at module loading time and used everywhere in the library. So generating elements with ReactDOM.render should not have been an issue, it had to come from somewhere else.
I ended up finding that the elements causing an issue were created by babel-runtime, because the logic from ReactElementSymbol was duplicated there, but with the presence of the polyfill: https://github.com/babel/babel/blob/v6.22.0/packages/babel-helpers/src/helpers.js#L20
There is an issue closed as ‘won’t fix’ on babel-runtime: https://github.com/babel/babel/issues/2517 because react won’t share the
REACT_ELEMENT_TYPEvariable.In my case, I am guessing that the issue is not due to our upgrade to 15.4 but a change of structure in our application. We can now understand why we need to import the polyfill beforehand, and it’s because of babel-runtime and not react.
Hope this will help others being in the same scenario.
I ran into this when adding
babel-polyfillto our react-redux app that was made using the asp.net core 2 template. This template splits up your webpack config into two separate configuration files (webpack.config.jsandwebpack.config.vendor.js). You need to modify thevendorarray inwebpack.config.vendor.jsand putbabel-polyfillat the top in order to get this to work.I also had to fully clean up my environment (namely delete the
wwwroot/distfolder) and rebuild the project in order for the changes to get properly picked up.This is expected to not work:
ES imports are hoisted by spec (which Babel follows). Even if you put
require()before it, it will be executed later.Use this lint rule to protect against this in the future.
I’m going to close this because it doesn’t appear to be a bug. It’s unfortunate this broke some apps but it’s very hard to protect against cases like this. In general my recommendation is that you should run any global polyfills before any other code in the bundle. Since polyfills are effectively modifying the environment, one should take care to do that consistently.