React – useRef with TypeScript and functional component
You require to extract the ref type elsewhere: interface RefObject { SayHi: () => void } then just refer to it in both places const Child = forwardRef((props: {name: string}, ref: Ref<RefObject>)=> { const {name} = props; useImperativeHandle(ref, () => ({ SayHi })); function SayHi() { console.log(“Hello ” + name); } return <div>{name}</div>; }); const … Read more