2015-11-20 49 views
3

新的反应0.14 StatelessComponent很好。然而,当有一个错误的渲染方法,反应过来仅此打印到控制台:更好的调试控制台输出的反应错误StatelessComponent

Uncaught Error: Invariant Violation: Objects are not valid as a React child 
(found: Mon Nov 23 2015 06:00:00 GMT+0100 (Central Europe Standard Time)). 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 `StatelessComponent`. 

有没有办法来标注与displayName的组成部分?

回答

4

试图找到解决方案已经:添加displayName到组件的功能类似:

const component = (props) => { 
    return (<div />) 
} 
component.displayName = "MyComponent" 
module.exports = component 

然后,反应聪明,因为它是将使用此displayName。你会从伟大的反应库中得到什么样的结果;)