-
Notifications
You must be signed in to change notification settings - Fork 3
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
Why is the value or checked prop required in the ref? #1
Comments
If you are not using a value / checked prop, you are using an uncontrolled component. This library is only meant to fix a race condition with SSR + controlled components. See https://reactjs.org/docs/forms.html#controlled-components. If I am misunderstanding your question / issue / wrong about controlled components, please provide a minimal example. |
I'm using controlled components, but for a few specific inputs I don't have React setting the value. For example, my password inputs have an onChange handler, but React doesn't set the value. This way if the user leaves the sign up page and comes back, the sign up form will have all fields filled in except for the password inputs. This seems to be an uncommon use case, and possibly not a React recommended approach, but it does work pretty well for what I'm trying to accomplish. |
I am still not sure that is a controlled component. So your goal with this library is to call I don't know how we'd see if a user has changed the value prior to React being loaded if the input state is not handled by React, but instead the native DOM. Maybe use a data attribute, such as I think with your use case might be better served with a standard Maybe I am still confused exactly how this input looks. Could you provide a minimal example? |
@johnnyodonnell Is this still an issue? If not, how did you solve the problem? |
This is still an issue. My workaround is to set the value attribute even though it's not the behavior I want. I can give you an example to help better explain why I think the value attribute should be optional. The site I am building is stacks.courses Steps:
Desired result: Actual result: If value is not a required attribute then I believe I can achieve the desired result. |
react-safe-universal-inputs/src/InputWrapper.js
Line 79 in 3e2b8b6
Currently my form inputs don't have value as a prop; and thus, this package does not work on my inputs. Is there a reason why value or checked is required?
The text was updated successfully, but these errors were encountered: