import React,{ useState, useRef } from 'react';import{ Table, Card, Button,} from 'antd';import ChildComp from './child';const FComp: React.FC<any>=(props)=>{
let child =useRef();;
let [text,setText]= useState<string>("我是父組件");
function onChild(){
console.log("subMitData", child.current.childMethod());
let childName = child.current.childMethod();setText(childName);}return(<ChildComp onRef={child}/><Button type='primary' onClick={onChild}>調用子組件</Button><h1>{text}<h1>