我想测量我的ScrollView
.
因此,我使用measure
from NativeMethodsMixin
:
import NativeMethodsMixin from 'NativeMethodsMixin'
我不太确定从这里去哪里,与此问题相关的大多数 SO 帖子似乎都已过时。
我知道我需要为ref
我创建一个ScrollView
(我做了并调用_scrollView
了它,我可以使用它来访问它this.refs._scrollView
)。
问题是,我不能像这样this.refs._scrollView
传入measure
:
NativeMethodsMixin.measure(this.refs._scrollView, (data) => {
console.log('measure: ', data)
})
然后我收到以下错误:
ExceptionsManager.js:61 findNodeHandle(...): Argument is not a component (type: object, keys: measure,measureInWindow,measureLayout,setNativeProps,focus,blur,componentWillMount,componentWillReceiveProps)
然后我尝试检索实际的节点句柄findNodeHandle
,并将其传递measure
到此github 问题中讨论的内容:
const handle = React.findNodeHandle(this.refs._scrollView)
NativeMethodsMixin.measure(handle, (data) => {
console.log('measure: ', data)
})
但这会导致相同的错误。有任何想法吗?