IE下报错“Objects are not valid as a React child”

发布于 2022-09-05 08:34:12 字数 1045 浏览 11 评论 0

错误描述:Objects are not valid as a React child. If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of Root.

我知道react child不能是一个对象,需转成数组或者字符串 ,但是我没在我的Root类里发现这样的错误,而且这个bug只在IE下出现,这个错误信息是指Root类本身有问题还是说Root类里所有可能渲染的组件有问题

import React, { Component, PropTypes } from 'react'
import { Provider } from 'react-redux'
import { Router, browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import routes from './routes'

export default class Root extends Component {
  render() {
    const { store } = this.props
    const history = syncHistoryWithStore(browserHistory, store)
        // render Root, and Router, which will load specific component when an URL is loaded
    return (
      <Provider store={store}>
        <div>
          <Router history={history} routes={routes} />
        </div>
      </Provider>
    )
  }
}```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老旧海报 2022-09-12 08:34:12

在入口文件前加入了babel-polyfill
参考:https://github.com/facebook/r...

entry: {
    'app': ["babel-polyfill", "./webpack/javascripts/react/index.js"]
}```
方觉久 2022-09-12 08:34:12

可能是使用了 IE 不支持的语法或者函数,导致最后的结果不是一个函数(React 组件都是函数)而是一个对象。

断点跟一下吧。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文