useFormikSlice feature that updates when I need #2089
Labels
Component: Formik
Focus: Performance
Enhancing Field and Form performance / rendering
stale
Type: Enhancement
Type: RFC
馃殌 Feature request
Current Behavior
Currently, when I need to access some form's values from deep nested components, if they are many, I use useFormikContext(), but it then gets updated and re rendered on every change to formik context (right?).
If I need to optmize this, I start using many useField()`s which already updates only if the value updates. But then it gets ugly quickly.
Desired Behavior
I would like some function which returns:
... useful things already present on useField but in a batch way.
Suggested Solution
Sort of useFormikSlice([field1, field2, field3]) maybe?
Types would be like
useFormikSlice< AllMyValues >([field1,field2,field3])
that returns things with Pick< AllMyValues, field1|field2|field3>
Who does this impact? Who is this for?
People aiming to optimize some uses with less code.
Describe alternatives you've considered
should keep things simple and just add an overload to useFormikContext() which accepts one arg "deps"?
Additional context
Sorry if this behaviour already exists somehow and I did not realize 馃榿
The text was updated successfully, but these errors were encountered: