react-final-form-arrays
                                
                                 react-final-form-arrays copied to clipboard
                                
                                    react-final-form-arrays copied to clipboard
                            
                            
                            
                        Significant performance degradation when using react-final-form-arrays
I have a lot of forms in expansion panel and all of them have arrays in them. I am seeing significant performance impact . On further investigation looks like Chrome performance timeline tool is pointing towards react-final-form-arrays.es.js:289 which is significantly slowing down user experience . From the time user clicks and the changes show up on screen is a lot.
@erikras Do you have any thoughts on how I can improve the experience.
Hmm.. I hated adding that setTimeout in #4, but I didn't see any other way around the problem in final-form/final-form#26.
Perhaps it will have to be revisited and thought about some more. 🤔
Having a big performance issue also, at least 1 second to render on input. Tried with 50 fields in my array, and each field is composed of 2 text inputs and some styled components.
Perf profile is pointing to https://github.com/final-form/react-final-form-arrays/blob/master/src/FieldArray.js#L127 (download here https://transfer.sh/xtamd/Profile-20181221T152943)
Do you have any recommendations ? How could I avoid re-rendering the whole list on user input ?
same issue here
Yes I'm trying to used posed animations and it's really bad... A list with 3 items and only a couple field still has 2+ seconds or delays and blocking
Any update on this? The performance is very poor with field array. I removed all the fields except the array field (with just two sub fields) and it is still the same.
The issue has not yet been fixed (final-form-arrays-3.0.2 and react-final-form-arrays-3.1.1). The way I was able to work-around the issue is to use React.Memo to memorize the component to reduce re-rendering (props only included values that were used in rendering of ExpantionPannel
const Test3 = React.memo((props)=> {
    const classes = useStylesExpantionPanel();
    return (<React.Fragment>
        <ExpansionPanel>
          <ExpansionPanelSummary  expandIcon={<ExpandMoreIcon />} >
            <Typography className={classes.heading}>Title</Typography>
          </ExpansionPanelSummary>
          <ExpansionPanelDetails>
            <TextInput source={`${props.source}.minWidth`} label="Min width" resettable />
            <TextInput source={`${props.source}.maxWidth`}  label="Max width" resettable />
            <TextInput source={`${props.source}.minHeight`} label="Min height" resettable />
            <TextInput source={`${props.source}.maxHeight`}  label="Max height" resettable />
            <TextInput source={`${props.source}.width`} label="Width" resettable />
            <TextInput source={`${props.source}.height`} label="Height" resettable />
          </ExpansionPanelDetails>
        </ExpansionPanel>
      </React.Fragment>
    );
  },
  (prevProps, nextProps)=> {console.log({prevProps, nextProps}); return _.isEqual(prevProps, nextProps)}
)
This way, when other form control are updated using user input, no re-rendering is taking place since this form is not re-rendered.
The project I'm working on has some large forms with dynamically generated nested field arrays so I figured I'd throw my experience out there in case it helps others. We were able to signifcantly improve overall form performance by setting the subscription and validateField props on appropriate elements. Out of the box final-form can re-render the form and individual fields a lot. That usually isn't a problem until you add arrays, nesting, or a lot of fields.
A couple of quick examples:
- Setting the subscription prop on the Form can significantly reduce the number of form-level re-renders. Try to set the subscription scope as narrow as possible. <Form subscription={{ submitting: true }}>See: final form subscription example
- Setting the validateField props on most fields was highly effective for us because it cuts down on cross-field validation and in the vast majority of cases validating a single field does not require the immediate validation of another. <Field name="name" validateFields={[]}>See: validateFields
- Adding memoization of components rendered inside a FieldArray helps prevent useless rendering of array children (and the cascading effect if you have nested arrays)
- Some of our team members had a misunderstanding of how the Field component prop worked and were passing inline functions to them. The component prop is using React.createElement under the hood and causes this to be recreated on every render which is obviously very expensive. Switching most Field definitions to use children was beneficial here.