如何“懒加载"现在已从 react-navigation 中删除了惰性选项卡导航器屏幕 [英] How to "lazy load" tab navigator screens now that lazy has been removed from react-navigation

查看:36
本文介绍了如何“懒加载"现在已从 react-navigation 中删除了惰性选项卡导航器屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

react-navigation 的维护者已经从库中删除了 'lazy: true',这导致所有选项卡都尝试一次呈现(并且之前由 lazy 控制的获取现在乱序触发).

The maintainers of react-navigation have removed 'lazy: true' from the library, causing all tabs to attempt to render at once (and fetches previously controlled by lazy now firing out of order).

为了保持类似的功能,您如何在第一次获得焦点之前强制在选项卡屏幕上等待不加载或调用获取调用?

In order to maintain similar functionality, how do you force a wait on a tab screen to not load or call fetch calls prior to being focused for the first time?

推荐答案

看来他们确实删除了它,但已决定在 v 1.1.2 中重新添加

It seems they did remove it, but have decided to add it back in v 1.1.2

https://github.com/react-navigation/react-navigation/releases/tag/v1.1.2

因此,您应该能够在您的 TabNavigatorConfig 对象中传递 lazy={true},然后标签在它们处于活动状态之前不会被呈现.为了进一步优化内存使用,您可以将其与 removeClippedSubviews 结合使用以从非活动选项卡中释放内存.

Thus, you should be able to pass lazy={true} in your TabNavigatorConfig object, and then tabs will not be rendered before they are active. To further optimize memory usage, you can couple this with removeClippedSubviews to free memory from inactive tabs.

这篇关于如何“懒加载"现在已从 react-navigation 中删除了惰性选项卡导航器屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆