[英]Performance trouble with FieldArray in react-final-form
I make an application where I use FieldArray component from react-final-form. 我制作了一个应用程序,在其中使用react-final-form的FieldArray组件 。 I have performance troubles with my components of Array.
我的Array组件遇到性能问题。 Each component also contains for about 8 Fields (each of them contain validation rule) (from react-final-form too) and when I add 50+ elements application's lagging (while rendering ALL components into virtual DOM and compare it with current DOM).
每个组件还包含大约8个字段(每个字段都包含验证规则)(也来自react-final-form),当我添加50多个元素时应用程序的滞后(将所有组件呈现到虚拟DOM中并将其与当前DOM进行比较)。 Anyone had this trouble?
有人遇到麻烦了吗?
How can I avoid this? 如何避免这种情况?
To prevent the entire list from re-rendering you can clear out all subscriptions in the FieldArray component. 为了防止整个列表重新呈现,您可以清除FieldArray组件中的所有订阅。
<FieldArray
name="myList"
subscription={{}} // This is required so that the whole array does not re-render on any change.
render={(fieldsProps) => (fieldsProps.fields.map((name, index) =>
{ (...your function here...) })
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.