在TypeScript中使用createRef创建动画.View时如何创建类型

在TypeScript中使用createRef创建动画.View时如何创建类型,typescript,react-native,Typescript,React Native,在React本机组件中创建ref时,如果没有提供正确的类型,Typescript会对此进行投诉 image = React.createRef(); state = { x: new Animated.Value(0), y: new Animated.Value(0), }; render() { const {x, y} = this.state; const imageStyle = {left: x, top: y}; return (

在React本机组件中创建ref时,如果没有提供正确的类型,Typescript会对此进行投诉

image = React.createRef();

state = {
    x: new Animated.Value(0),
    y: new Animated.Value(0),
};

render() {
    const {x, y} = this.state;
    const imageStyle = {left: x, top: y};

    return (
        <Animated.View
            ref={this.image} // I got warning message here
            {...this.responder}
            style={[styles.draggable, imageStyle]}>
            {this.props.children}
        </Animated.View>
    )
}

const styles = StyleSheet.create({
    draggable: {
    position: 'absolute',
    height: itemWidth,
    width: itemWidth,
    },  
});
image=React.createRef();
状态={
x:新的动画值(0),
y:新的动画值(0),
};
render(){
常数{x,y}=this.state;
常量imageStyle={left:x,top:y};
返回(
{this.props.children}
)
}
const styles=StyleSheet.create({
可拖动:{
位置:'绝对',
高度:项目宽度,
宽度:itemWidth,
},  
});
我收到了这个警告

键入“{children:ReactNode;style:({left:Value;top:Value;}{ 位置:“绝对”;高度:数字;宽度:数字;})[];当前: 未知;ref:reObject;}'不可分配给类型 “内在颂词和动画道具&{儿童?: ReactNode;}。类型上不存在属性“ref” “内在颂词和动画道具&{儿童?: ReactNode;}'

createRef
行需要类似
image=React.createRef()

但是我不知道如何创建这个
某些类型的
更新
@types/react native
版本解决了这个问题

"@types/react-native": "^0.61.15", -> "@types/react-native": "^0.63.37",

更新
@types/react native
版本解决了问题

"@types/react-native": "^0.61.15", -> "@types/react-native": "^0.63.37",