Skip to content

Bug: Uncontrolled <input /> element has value attribute removed #32576

New issue

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

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

Already on GitHub? # to your account

Open
imjordanxd opened this issue Mar 12, 2025 · 3 comments
Open

Bug: Uncontrolled <input /> element has value attribute removed #32576

imjordanxd opened this issue Mar 12, 2025 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@imjordanxd
Copy link

React version: React 19

Steps To Reproduce

  1. Pass an value={undefined} as a prop to an <input /> element
  2. Observe the DOM and see the value attribute is absent

Link to code example:

React 18

React 19

The current behavior

React 18 passed a booleanish attribute i.e. <input value />. React 19 omitted the attribute altogether i.e. <input />. This is causing a lot of failures in our snapshot tests. I'm not sure if this behaviour is expected in React 19 and I can't find anything in the release notes apart from this loosely related PR. If this behaviour is expected in 19, it would be great to mention that somewhere!

@imjordanxd imjordanxd added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 12, 2025
@narekmalk
Copy link

Can I take this issue?

@ronak-create
Copy link

Use defaultValue Instead of value

If you're dealing with uncontrolled inputs:

<input defaultValue={someValue} />
  • defaultValue does suffer from the undefined issue in React 19.
  • Useful for forms where React doesn't need to control the value.

@codeAdityagithub
Copy link

It is expected behaviour, as falsy values for attributes won't parse those values and thus not appear on the dom.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants