【发布时间】:2019-04-03 21:34:37
【问题描述】:
const header = ReactDOMServer.renderToString(<MyComponent testprops={this.props.testprops} />)
我收到“元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:对象。”仅在 Internet Explorer 11 中发布。
当我删除上面的代码时,它工作得很好,我需要带有标题的 window.print() 的 abpve 代码
修复:
const MyComponent = React.memo(props => {
return (<span>Testing</span>)
})
改为
class MyComponent extends PureComponent {
return (<span>Testing</span>)
}
React.memo 抛出错误
【问题讨论】:
-
你能粘贴
MyComponent的代码 -
它是一个 React.memo 导出的,我改成它工作的功能组件
-
从您上次的评论来看,您的问题似乎已解决。我建议您将您的解决方案作为答案发布,并尝试在 48 小时后将您自己的答案标记为该问题的可接受答案,此时可以标记。它可以在未来帮助其他社区成员解决类似的问题。感谢您的理解。
标签: reactjs internet-explorer-11