【发布时间】:2018-06-14 20:43:26
【问题描述】:
我试图通过React library 理解React,但无法理解context 和updater 是什么,它们传递给组件。
以下是库中的代码。
function Component(props, context, updater) {
this.props = props;
this.context = context;
this.refs = emptyObject;
// We initialize the default updater but the real one gets injected by the
// renderer.
this.updater = updater || ReactNoopUpdateQueue;
}
这些东西的目的是什么?
【问题讨论】:
-
你看过
ReactNoopUpdateQueue或 React 代码库中具有类似名称的方法的任何其他对象吗?他们可能会回答你的一些问题:-) -
嗨@SeanVieira,谢谢你的帮助,我也无法从那个文件中理解,如果你有时间,你能简要介绍一下吗?谢谢。
标签: javascript reactjs react-component