2015-11-20 40 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。你會從偉大的反應庫中得到什麼樣的結果;)