0%

React 在 IE 11 下無法顯示

錯誤訊息

1
typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103

會出現這個問題的原因是因為 react 和 react-dom 所使用的 polyfill 的版本不同
需要在 webpack.config => entry 中的第一行加入所要用的 polyfill 版本

1
2
3
4
5
6
7
entry: [
'babel-polyfill', // Load this first
'react-hot-loader/patch', // This package already requires/loads react (but not react-dom). It must be loaded after babel-polyfill to ensure both react and react-dom use the same Symbol.
'react', // Include this to enforce order
'react-dom', // Include this to enforce order
'./index.js' // Path to your app's entry file
]

or somthing like this

1
2
3
4
5
6
entry: [
require.resolve('react-app-polyfill/ie11'),
isEnvDevelopment &&
require.resolve('react-dev-utils/webpackHotDevClient'),
paths.appIndexJs,
],