React.js中所有者和父组件之间的区别是什么
React 0.13带来了基于父级的上下文,而不是基于所有者的上下文。
React 0.13 brings parent-based context instead of owner-based context.
所以,我不太明白所有者和父组件之间的区别。将举例说明。
So, i can't quite understand the difference between owner and parent components. Examples will be appreciated.
var A = React.createClass({
render() {
return (
<B>
<C />
</B>
);
}
});
在上面的示例中,A是B和C的所有者,因为A创建了两个组件。
In the above example, A is the owner of B and C, because A creates both of the components.
但是,B是C的父,因为C作为子传递给B。
However, B is the parent of C because C is passed as child to B.
更多信息可在文档中找到。
将owner-ownee
关系与父子关系区分开来非常重要。 owner-ownee
关系特定于React,而亲子关系
只是你知道并喜欢DOM的那个。
It's important to draw a distinction between the owner-ownee relationship and the parent-child relationship. The owner-ownee relationship is specific to React, while the parent-child relationship is simply the one you know and love from the DOM.