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
Hi!
thanks for the lib! One question: I'm using InputField and find it not ideal that the value of the entered text is stored in the state of the component and it is therefore possible for it to drift away from the value that is in my state object.
More specifically: I have my state object that contains the value that the text field should display. Say I render the textfield with value={this.state.value} (renders ok) then I change the value somewhere else which triggers a re-render. The InputField will ignore this new value. What I can do is use the setValue but I believe that goes against React.
So my question is - is it feasible to remove the value from state altogether (?), or alternatively implement componentWillReceiveProps? It doesn't seem difficult to get rid of it, looking at the code.
This might apply to other components too.
edit: so I tried both (getting rid of it & componentWillReceiveProps) and they seem to work both with no problem.
The text was updated successfully, but these errors were encountered:
vonovak
changed the title
[InputField] make value a controlled prop
make values a controlled prop
Aug 23, 2016
vonovak
changed the title
make values a controlled prop
make displayed values a controlled prop
Aug 23, 2016
I'm completely pro componentWillReceiveProps, because for some users is fundamental to set values in the fields programmatically.
This behavior it's allowed in react and the internal state of the component is handled correctly.
I'm going to do a new release with this and other changes.
If you have any other suggestion I'm more than happy to help.
Thank you.
Hi!
thanks for the lib! One question: I'm using
InputField
and find it not ideal that thevalue
of the entered text is stored in the state of the component and it is therefore possible for it to drift away from the value that is in my state object.More specifically: I have my state object that contains the value that the text field should display. Say I render the textfield with
value={this.state.value}
(renders ok) then I change the value somewhere else which triggers a re-render. TheInputField
will ignore this new value. What I can do is use thesetValue
but I believe that goes against React.So my question is - is it feasible to remove the value from state altogether (?), or alternatively implement componentWillReceiveProps? It doesn't seem difficult to get rid of it, looking at the code.
This might apply to other components too.
edit: so I tried both (getting rid of it & componentWillReceiveProps) and they seem to work both with no problem.
The text was updated successfully, but these errors were encountered: