【发布时间】:2016-06-02 20:17:15
【问题描述】:
我想得到 ReactDOM.findDOMNode(this) 的孩子 这样我就可以根据参考进行样式设置。专门显示 none 一些 refs 和 yes 其他的。
我以为我可以
blockNode = ReactDOM.findDOMNode(this).children
React.Children.map(blockNode, function(el) {
console.log('el ',el);
})
错误响应:
invariant.js:39 Uncaught Invariant Violation: Objects are not valid as a React child (found: [object HTMLDivElement]). 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.
附:还尝试在 createFragment() 中包装 blockNode,但效果不佳
【问题讨论】: