【发布时间】:2020-10-10 02:17:00
【问题描述】:
我在子组件中有一个 iFrame,并且想将 iframe 的 ref 传递给父组件,以便我可以对 iframe 执行 postMessage。我不确定如何实现从孩子到父母的转发参考。
谢谢!
【问题讨论】:
-
尝试使用从父组件到子组件的回调。不确定这是否可行,但这似乎是将某些东西从孩子传递给父母的唯一方法。
-
我有一个类似问题的答案,How to set one component's state from another component in React -- 这里我讨论如何设置子引用。希望这会有所帮助!
标签: javascript reactjs next.js