我想测量我的内容的大小ScrollView
.
因此,我正在使用measure
from NativeMethodsMixin
:
import NativeMethodsMixin from 'NativeMethodsMixin'
我不太确定从这里去哪里,大多数与这个问题相关的帖子似乎已经过时了。
我明白我需要创建一个ref
to my ScrollView
(我这样做并称之为_scrollView
,我可以使用它访问它this.refs._scrollView
).
问题是,我不能直接通过this.refs._scrollView
into 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问题 https://github.com/facebook/react-native/issues/1060:
const handle = React.findNodeHandle(this.refs._scrollView)
NativeMethodsMixin.measure(handle, (data) => {
console.log('measure: ', data)
})
但这会导致同样的错误。有任何想法吗?