// 子组件
function Child(props,ref){
useImperativeHandle(ref,()=>({
childMethod(){
}
}))
}
export default forwardRef(Child)
// 父组件
function App(){
const childRef=useRef(null)
const handle=()=>{
childRef.current.childMethod()
}
return (
<div>
<Child ref={childRef} />
</div>
)
}