-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
参考资料
问题产生
在antd中想要在上层函数式组件获取到下级组件中的一些方法
function Parent() {
const childRef = useRef(null)
return (
<div>
<Child ref=childRef />
</div>
)
}
// -------------------
function Child(props, ref) {
const [form] = Form.useForm() // antd的form实例
ref.current = form // 这时候父组件就能通过childRef去调用子组件的form方法了
return (
....
)
}
export default React.forwardRef(Child)