Search code examples
javascriptexpressinternet-explorercreate-react-app

create-react-app with express server not rendering in IE


My app works great with Chrome and Safari. It's a react app with an express backend. When I open it in IE it renders a white page and I get this error:

enter image description here

Ive tried looking up the error and I could find a solution.

Thanks !


Solution

  • It's because the Object.assign method isn't supported in IE. You'll need a polyfill to make it work in IE. You can check Mozilla for a working polyfill.

    Where you place the polyfill depends on how your app looks like. The only thing that's important is that it's loaded before your other scripts. You can put in a JS file and load it before your other JS files.

    <script>
    ... Polyfill script
    </script>
    
    <script src="react-app.js"></script>
    

    Since your building a React application I assume you're using some kind of bundler, eg webpack. Then a good practice would be to use babel to transpile your code to ES5 (which all major browsers can handle). Babel will also a lot of other features and benefits. I propose that you read more about that.