Stateless function components cannot be given refs. Attempts to access this ref will fail.
<div>
<ListView
ref={ el => this.lv = el }
dataSource={ this.state.dataSource }
renderScrollComponent={ () => <MyBody /> }
renderRow={row}
onEndReachedThreshold={100}
onEndReached={this.getList}
style={{
height: '500px',
overflow: 'auto',
}}
/>
</div>
在使用的时候报这个错
而且为什么react有时候使用 refs 只能获取组件实例 不能获取真实的dom节点?
这个异常的解决方式是把
stateless
组件修改为class
。但是你引用的是第三方的。所以这个方式应该无效。
所以你不能在
ListView
组件中用refs
来获取数据,只能通过其他方式获取,比如回调。再次强调,使用
react
就忘掉真实dom
吧。不要尝试获取真实dom
,也不要操作真实Dom