jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
34k stars 2.79k forks source link

Formik performance enhancements #2221

Open wallymathieu opened 4 years ago

wallymathieu commented 4 years ago

🚀 Feature request

Current Behavior

The current behavior is to send relatively large chunks of information to the reducer.

For instance when dealing with an array of values the change is sent for the entire array. HandleChange computes change when it instead it could be sent to the reducer.

Dispatch and state is in the same context.

Desired Behavior

The desired behavior is to send "smaller" messages in order to let the reducer do the work.

Having dispatch and state in the same React context can if we believe this post impact performance.

Suggested Solution

Send messages such as :

That way ArrayHelpers could contain less state.

Split Formik React context into two parts.

Who does this impact? Who is this for?

People who have very large forms using FieldArray. Removing return values from array helpers could change the API slightly. In order to avoid having an impact on people using specific parts of the FieldArray API you could have an alternate version with a slightly different API and a new name.

Describe alternatives you've considered

Using a fork of Formik without regard for backwards compatibility (that can be used alongside Formik): https://github.com/wallymathieu/formik-reimagined

Additional context

wallymathieu commented 2 years ago

Perhaps this should be closed, since the perf is good enough for many implementations? @jaredpalmer