对象无效作为React子对象(在Internet Explorer 11中,用于React 15.4.1) [英] Objects are not valid as a react child (In Internet explorer 11 for React 15.4.1)
问题描述
对象作为React子对象无效(找到:带有键{$$ typeof,类型,键,ref,props,_owner,_store}的对象).如果您打算渲染孩子的集合,请改用数组,或使用React附加组件中的createFragment(object)包装对象.检查
App
的呈现方法.
AppContainer:
AppContainer :
const mapDispatchToProps = (dispatch) => {
return {
}
}
}
}
组件:
class App extends Component {
render() {
return (
);
}
}
上面是我对app.js的渲染功能.此代码在谷歌浏览器中可以正常工作,但在访问Internet Explorer时却无法正常工作,并且会引发上述错误.
Above is my render function for app.js. This Code is working fine in google chrome, but when coming to Internet explorer It is not working and it is throwing the above error.
推荐答案
React 15.4 with IE11以来的问题
如果您仍然遇到此问题,则可以查看此关于React 15.4和IE11的问题#8379 .我在webpack开发人员模式/IE11/React 15.4中遇到了同样的问题,而且似乎React和ReactDom都使用了自己的Symbol polyfill版本(这是15.4中的新功能):
A problem since React 15.4 with IE11
If you still have this issue, you may have a look at this react issue #8379 about React 15.4 and IE11. I had the same problem with webpack dev mode / IE11 / React 15.4, and it seems that React and ReactDom each use their version of a Symbol polyfill (this is new with 15.4):
以某种方式做出反应,而反应域不再同意".在
$$ typeof
值
应为 Symbol&& Symbol.for&& Symbol.for("react.element")|| 60103
的类型.
解决方案
我已经通过重新排序 polyfill
和 react
/ react-dom
来解决此问题,以确保在React之前已加载polyfill符号和ReactDom的符号...现在,他们同意"在$$ typeof值上.
Solution
I've resolved this issue by reordering polyfill
and react
/ react-dom
to be sure that the polyfill Symbol is loaded before React and ReactDom's Symbol... Now they "agree" on $$typeof value.
用于webpack的示例解决方案:
Example solution for webpack:
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
]
这篇关于对象无效作为React子对象(在Internet Explorer 11中,用于React 15.4.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!