import React , { useImperativeHandle , forwardRef , useState } from 'react' ; import { Button } from 'antd' ; export default forwardRef ( ( props , ref ) => { const [ preVal , setPreval ] = useState ( 'hello' ) ; useImperativeHandle ( ref , ( ) => ( { preVal } ) , [ preVal ] ) ; return ( < div > < Button onClick = { ( ) => setPreval ( 'word' ) } > { preVal } < /Button> < /div>); } ) ;