You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Controlled inputs with the type=number are not setting the defaultValue when the value state is altered. This causes the state and value to become out of sync when a form is reset (for instance after a form action is sent).
#29862
The issue arises because the useEffect hook depends on both value1 and value2, causing the value not to update properly. By removing the dependencies on value1 and value2, the component functions correctly.
@Sunilverma99 you're inspecting the wrong values there. This issue is specifically around the defaultValue that is set so when a form is reset the values are not correct. If you inspect the element you can get a better example of what is happening here. All other input types will have the html attributes change except type=number
This might be a better example of the exact issue I'm facing. If you input hit the enter key while focused in the number input the field value will be erased on the form submit even though the state is still the old value.
Summary
Controlled inputs with the
type=number
are not setting thedefaultValue
when the value state is altered. This causes the state and value to become out of sync when a form is reset (for instance after a form action is sent).https://codesandbox.io/p/github/BrendonSled/react-19-controlled-input-number-bug/
The text was updated successfully, but these errors were encountered: