在文档中它说挂载,卸载。但我看到每次主人收到道具时都会打电话给他们。
<A>
<B ref={(component) => console.log(blah)}>
</B>
<A>
任何人都可以确认预期的行为吗?
我唯一的另一个想法是另一个HOC正在干扰。我正在使用react-dnd
它确实包装了 ref 回调。
refs 的代码位于下面的链接中,但我似乎无法解决。
https://github.com/facebook/react/blob/38acadf6f493926383aec0362617b8507ddee0d8/src/renderers/shared/reconciler/ReactRef.js
我假设它们在render
上运行,因为在此之前您没有 DOM 引用。