react的Element type is invalid: expected a string (for built-in components) ...错误

react中遇到的错误类型如下:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of “XXX"

Rreact Native 常见错误总结 文章中总结:可能是render中引用的组件没有正确导出为defaultexport defalut XXXComponent。

除了上述原因此外,我个人在使用CommonJS的require()来导入组件,同样出现了这样的问题,当不用require,而使用import xxx from './xxx'来导入组件的时候,就不会出现这种类型的错误了。

猜你喜欢

转载自blog.csdn.net/jiuzaizuotian2014/article/details/81635538
今日推荐