Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 19: Warning: A props object containing a "key" prop is being spread into JSX from getCollectionProps #620

Open
lifeiscontent opened this issue Apr 30, 2024 · 2 comments

Comments

@lifeiscontent
Copy link
Contributor

Describe the bug and the expected behavior

in React 19 key throws a warning when coming from props, and in the props from getCollectionProps it returns key

Conform version

v1.x

Steps to Reproduce the Bug or Issue

using React 19, use getCollectionProps and spread the values into a checkbox / radio to see the warning

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

@mike1o1
Copy link

mike1o1 commented May 1, 2024

Possible duplicate of #600

@edmundhung
Copy link
Owner

I assume you are talking about the props object that we spread on the input element right?

// Example from the `getCollectionProps` docs
import { useForm, getCollectionProps } from '@conform-to/react';

function Example() {
  const [form, fields] = useForm();

  return (
    <>
      {getCollectionProps(fields.color, {
        type: 'radio',
        options: ['red', 'green', 'blue'],
      }).map((props) => (
        <label key={props.id} htmlFor={props.id}>
          <input {...props} />
          <span>{props.value}</span>
        </label>
      ))}
    </>
  );
}

I have a working solution that remove the need to pass the key on uncontrolled inputs. But I am still confirming how it would pair nicely with controlled input. I will share more next week :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants