Skip to content

2.4.4 is a Breaking Change - passing "className" this new way overwrites existing "className" in composed components #3883

Open
@shaunaas

Description

Bug report

Current Behavior

2.4.4 unexpectedly broke all of my fields.
The way the code is implemented, className becomes required and overwrites all my classNames that exist on my composed components being passed into <Field component={MyCustomComponent} />

Expected behavior

className does not become a required prop

Reproducible example

const CustomInput = (props) => { return ( <div> <input type="text" className="composed-component-classname" {...props} /> </div> ); };

<Field name="name" component={CustomInput} />

Suggested solution(s)

  1. Revert this change. Passing "className" was already supported via ...rest props and a component that either spreads/or specifically requires any specific props to be passed.

Additional context

  • passing className after the ...rest in the formik lib will overwrite any existing className prop already on the input

Your environment

Software Version(s)
Formik 2.4.4
React 18.2.0
TypeScript N.A.
Browser Any
Yarn 1.22.19
Operating System macOS 13.5.1 (Ventura)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions