React.ForwardedRef与useRef创建的ref值对应类型React.MutableRefObject,会报错

正确写法

ref?: React.ForwardedRef<YakitAutoCompleteRefProps>

interface YakitAutoCompleteRefProps {
    onSetRemoteValues: (s: string) => void
    onGetRemoteValues: () => void
}

const downstreamProxyRef: React.MutableRefObject<YakitAutoCompleteRefProps> = useRef<YakitAutoCompleteRefProps>({
    onGetRemoteValues: () => {},
    onSetRemoteValues: (s) => {}
})

你可能感兴趣的:(react.js,前端,ts)