Skip to content

RFC: Improving Field #1371

@jaredpalmer

Description

@jaredpalmer

I want to take folk's temperature on some warts that I want to change related to <Field> as well as discuss how best to move forward in a way that doesn't force people to rewrite stuff immediately.

<Field component>

This prop is the source of a ton of confusion because it does not simply pass through onChange, onBlur, and value but rather field and form. This means that there is some inconsistent behavior with respect to <Field component="select"> vs. <Field component={MyInput}>. I think a decent solution is to create a new prop called is or as and make that prop just pass through onBlur, onChange, value/checked as expected. We then would put a deprecation warning on component instructing people to use as/is or children and eventually remove component entirely in future versions. Unfortunately, this will force folks to change every single "select" and "textarea" over time, but this at least avoids breaking changes

<Field render>

This is just redundant at this point. We should put up a deprecation warning suggesting to use children as a function.

<Field children>

We should merge #343 and add a meta to <Field children>.

<Field>
-  {({field, form }) => ... }
+  {({field, form, meta }) => ... }
</Field>

Next Steps

In a perfect world, we make these changes gradually in a way that prevents people from having to rewrite stuff. I definitely don't want to have to rewrite all my inputs, but we need to make these changes at some point. We also need to consider that <Field> will have a dramatically reduced usage in the future once the useField hook is released.

Umbrella Issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions