react-native - 在 ScrollView 和 FlatList 中引用子视图(div)
问题描述
长话短说,我正在努力将电视支持添加到 react-native-web。这允许 Touchable 具有焦点的想法,AndroidTV 和 AppleTV 会根据具有焦点的项目自动滚动 ScrollViews 和 FlatLists。
我使用 scrollToIndex 等可以正常工作,但在某些情况下,我需要访问 Scroll 或 FlatList 的子滚动 div 以供参考 FlastList 创建一个包装 div,它代表带有内部 div 的 scrollView 的“窗口”包装视图中的所有项目。
请先原谅我,因为我的大多数用例都是水平滚动的,所以我经常混淆宽度/高度,那么“标准”是什么
基本上,我试图找到“惯用的”反应原生方式来获得对该内部 div 的引用。这仅适用于网络,因为我正在复制本机功能。
<div> <-- Container div, width/height is width/height of Scroll View, the "ref" I can get a node from -->
<div> <-- I Want this "ref" - Inner div, width/height is width/height of all its children, overflows parent with enough items -->
<div> <-- All the children -->
<div>
....
<div>
</div>
我可以使用scrollview ref的firstChild访问节点并使其工作。这很好,但依赖于 HTML 的一些一致性,所以它看起来“脆弱”。有一些方法,如 'getScrollableNode' 和 'getNativeScrollRef' ,它们看起来可能有效,但它们要么不存在,要么引用父节点。
解决方案
推荐阅读
- javascript - 如何从 Chrome 扩展程序中查找文本框
- javascript - const_url 中的固定链接
- sql - 将值插入PostgreSQL中的数组列
- windows - 通过 .bat 文件将应用程序启动到全屏模式
- javascript - 尝试递减时,for循环打印“未定义”
- python-3.x - 使用 PyExifTool 将 exif 数据写入 exif 标头
- java - 不兼容的类型不能转换为 Fragment
- webpack - babel-polyfill 和 webpack 出错
- javascript - 从网站调用 Nodemailer 脚本时不执行
- amazon-web-services - aws api 网关端点不是公共的