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

2023-12-13 07:04:34

正确写法

ref?: React.ForwardedRef<YakitAutoCompleteRefProps>

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

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

文章来源:https://blog.csdn.net/qq_36904182/article/details/134873680
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。