新反应0.14 StatelessComponent很不错。但是,当其render方法出错时,react仅将其打印到控制台:
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
注释组件?
答案 0 :(得分:4)
通过尝试找到解决方案:将displayName
添加到组件函数中:
const component = (props) => {
return (<div />)
}
component.displayName = "MyComponent"
module.exports = component
然后,按照原样做出反应,将使用此displayName
。那种你期望从伟大的反应中获得的东西;)