How to make React app created by create-react-app support IE11

Viewed 405

I have a simple react app created by the latest version of create-react-app (that only support node version 14+). I am trying to make this app run in IE11. So as recommended, I did following:

  • installed react-app-polyfill
  • added two imports at the beginning of index.js: import "react-app-polyfill/ie11", import "react-app-polyfill/stable"
  • added "ie 11" under the development in the package.json

I installed a chrome extension, IE Tab, and tested there. But still not working, I see following error when I open the chrome devtool: IE: Error: Object doesn't support property or method 'endsWith'. Source: http://localhost:3000/static/js/bundle.js:63700

Can anyone help?

2 Answers

I can reproduce the issue. You can add a polyfill for endsWith() so that it can work well in IE 11.

You can include the polyfill within <script> tag in index.html.

enter image description here

Found this solution on the 3rd page of google. It's going to help you:

  • The first thing you have to do - include polyfills from react-app-polyfill at the top of your app

  • Then in package.json set up browserlist (add ie11, ie10, etc)

  • In the end - add meta tag in your public/index.html

Related