'Symbol' is undefined in IE after using babel

前端 未结 6 1395
臣服心动
臣服心动 2020-12-02 15:12

I have a reactjs app written using ES6 standards, and I use webpack to build it. The webpack loads the js modules using <

6条回答
  •  失恋的感觉
    2020-12-02 15:41

    This solution will work for sure, it worked for me when I encountered the error: 'Symbol' is undefined in IE . It worked earlier in Chrome and Firefox but IE was throwing this error.It took me few hours to find this solution. I am using the latest React at this time react "react": "^16.5.0" on windows machine.

    1. Install babel-polyfill
    npm install --save-dev babel-polyfill
    In package.json, it should have the following entries
    
    "devDependencies": {
        "babel-core": "^6.26.3",
        "babel-loader": "^8.0.2",
        "babel-polyfill": "^6.26.0",
        "babel-preset-react": "^6.24.1"
      }
    
    2. In index.js, add
    
        import babelPolyfill from 'babel-polyfill';
    

    Problem should get solved

提交回复
热议问题