【发布时间】:2019-03-17 11:10:34
【问题描述】:
我正在尝试弄清楚我需要如何使用React.createRef() 与 typescript 进行本机反应,因为以下代码会引发错误
// ...
circleRef = React.createRef();
componentDidMount() {
this.circleRef.current.setNativeProps({
someProperty: someValue
});
}
// ...
当前为this.circleRef.current.setNativeprops 引发以下错误
[ts] 对象可能为“空”。 (财产) React.RefObject.current: {} |空
和
[ts] 类型“{}”上不存在属性“setNativeProps”。任何
有什么想法吗?
【问题讨论】:
标签: reactjs typescript react-native react-ref