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
What's the correct way to update <input/> default value? #699
Comments
Your input will have local state, but you can connect it to redux on entry (component did mount, in your case) and on submit (or on change if you must act on the data immediately). |
Thanks for help. |
You may want to use Remember, the goal here is predictability and reliability. It may involve more steps to get the job done, but you'll end up with less gotchas and unexpected behavior. And on top of that, you can layer developer ergonomic tools like redux-devtools and webpack to enable hot reloading and time travel. |
Sounds like you are wanting to use uncontrolled components. Check out the React Docs if you are unsure. With uncontrolled components you can just use Although many recommend against uncontrolled components and using |
That's not how If you want to set values programmatically later in React's declarative manner, you'll have to make it a controlled input. In this case you'll have to provide always-up-to-date |
I have a input tag:
<input type='text' />
when component did mount, I send ajax request and get a value.
Then I want to set this value as the input's
defaultValue
property.Without redux, I might use local state, set this value to input's 'value' property and add an onChange function.
What's the correct way to do this in redux?
The text was updated successfully, but these errors were encountered: