简体   繁体   English

React Native-缓存DOM?

[英]React Native - cache DOM?

I have a component in React Native that needs to render pretty big array. 我在React Native中有一个需要渲染很大数组的组件。 That array is an in memory object and it takes about one second to render whole view. 该数组是一个内存中对象,大约需要一秒钟呈现整个视图。

So it's not a big deal when the app is showing up but there are couple of other screens that user can navigate to and when he navigates back it takes again around one second to render that view. 因此,当应用程序显示时,这没什么大不了的,但是用户可以导航到其他几个屏幕,当他向后导航时,大约需要一秒钟才能呈现该视图。 And that's pretty annoying. 这很烦人。

Is there any way I could render a component once and keep it in some cache or something? 有什么办法可以一次渲染一个组件并将其保存在某些缓存中? So that when user navigates out and get's back to this view it will be shown immidiately? 这样,当用户离开并返回到该视图时,将立即显示该视图吗?

Thanks in advance. 提前致谢。

I'd suggest rendering in chunks of size n (whatever gives you best-perceived performance) instead of rendering the entire 250 item list. 我建议渲染大小为n块(无论如何提供最佳的性能),而不是渲染整个250个项目列表。

Did some more digging on caching react views and found this https://github.com/zhaoyao91/react-view-cache . 在缓存方面做了更多的研究以响应视图,并发现了这个https://github.com/zhaoyao91/react-view-cache Haven't tried it myself but maybe it helps. 我自己还没有尝试过,但也许有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM