[英]Loading React Components in parallel?
Is there a way to structure your code such that components will load in parallel or asynchronously? 有没有一种结构化代码的方式,以便组件可以并行或异步加载?
Currently my structure is: 目前,我的结构是:
<Stream>
{listOfArticles }
</Stream>
The {listOfArticles} creates an array of articles, and each article is set to load from the Embedly Card API, so the network tab shows a staggered, linear loading that takes up to 10seconds for 25 items. {listOfArticles}创建一个文章数组,并且每个文章都设置为从Embedly Card API加载,因此“网络”标签显示的交错线性加载时间长达25秒,耗时10秒。
thanks! 谢谢!
Generally, it is not ideal to keep data in React's state (you generally only want React states to track UI states, not data models). 通常,将数据保持在React状态是不理想的(您通常只希望React状态跟踪UI状态,而不是数据模型)。 You should keep your data isolated in models or store, and use actions or events to load data via api (see Flux ) 您应该将数据隔离在模型或存储中,并使用操作或事件通过api加载数据(请参阅Flux )
But to answer your question, you can use something like react-async to create async components 但是要回答您的问题,您可以使用诸如react-async之类的方法来创建异步组件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.