Skip to content

Performance problems due to validations when having much fields #230

Closed
@Benadev

Description

@Benadev

Are you submitting a bug report or a feature request?

Performance-Issue

What is the current behavior?

Thanks for building and maintaining such an amazing lib. We already ported a bunch of redux-forms to final-form without any issues. Hacky solutions in redux-form are becoming really straight on and simple.

Now we stumbled over a strong performance issue which sometimes crashes the browser. If a form with many fields (eg. 100+) renders first time, the function passed to validate-prop of the Form-Component gets called more than 100 times. The problem seems to be, that preparing data which is passed to the validate-function seems to be quite expensive (see screenshot, getIn). An idea: A few weeks ago I read an issue in react itself which shows that usage of Object.assign seems to be quite expensive. In older browsers where methods like Object.assign gets polyfilled the performace seems to be even worse.

It does not depend on using field-arrays or normal fields. It seems to depend only on the count of fields itself.

What is the expected behavior?

Blazing fast! ;)

Sandbox Link

We made an example where you can reproduce it easily, and see the number of validations.
Take care that a large number of rows will crash your browser :-).
You can control the test-app by setting the following two values:
let noSideEffects = false; // if true no extra logic, only prints to console, if false it shows a counter
let rowCount = 40; // count of rows which get passed to initialValues-prop.

Here is the sandbox-link:
https://codesandbox.io/s/nw9zm0yykj

What's your environment?

any browser, most actual versions of all libs

Other information

Furthermore we analyzed it a little bit:
It seems that a function called "getIn" is mainly responsible for the large duration, see attached Screenshot.

finalform_analyzation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions