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
DefaultValue is empty :( #2764
Comments
Your code there doesn't run so it's a bit tricky to actually see the problem. My gut is that you're expecting |
I'm sorry, the "modal" component receives a props where the value is a state of the component "AppNotas", when I click on a link that is in the "Collapse" run a function of "AppNotas" that makes a change in state that is rightly the props of "modal" bringing only 1 object to the model. This props the "modal" appears anywhere in the render, however in the form fields (input for example) using the defaultValue it does not appear the data, but if I only use the value he appears, if I set a value in the defaultValue he appears, one thing that does not appear in the defaultvalue is the value of the props |
It sounds like the props are empty on first render? Since we only look at I really think you want to make use of controlled inputs here. I meant to paste the link last time - http://facebook.github.io/react/docs/forms.html#controlled-components |
Yes initially the props "dados" is empty, but the form does not appear too, when I click to open the modal the props is updated and receives the due value ... the big problem is not the props, because if I display it anywhere appears normal, even if I set the input with value
|
You're right that the big problem is not props BUT it's important to understand that the fact that props change is the reason you are having a problem. Yes, the first code you wrote will update the value when props are updated. This is because There's a misunderstanding happening here but no bug with React so I'm going to close this out. |
OMG Sorry Paul Solution: Thank you very much |
use componentWillMount(){ this.setState({key:this.props.defaultvalue});} |
@kevenjesus.. Since we are also using the modal, I did understand that we have to use ref for my input type to bind values. but how will componentDidUpdate work. Appreciate your help. |
Hello everybody okay?
I have quite a strange problem, when seto a value in the "defaultValue" nothing appears, however if I set a value using "value" appears, the props is coming with the data correctly, I have no idea what it is
my react conde http://jsbin.com/losugiqoje/2/edit?html,js,output
The text was updated successfully, but these errors were encountered: