I am following material-ui instructions form http://www.material-ui.com/#/ . but the problem is getting htlm elements value in react.
this is text field component < TextField ref=“txtTo”/>.
trying to get value from it like
const vdate=this.refs.txtDate.getValue();
const vReason=ReactDOM.findDOMNode(this.refs.txtDate).value; .</li?
but when i call from DOM its return undefined.
they refereed getValue(). but I have got error on console, "getValue() not a function. how to resolve it?
Using refs is not encouraged anymore. The better way is to either use a state manager like redux or manage your own state. Change your state on events happening in TextField like onChange or onBlur etc.
I had a serious problem with this approach. I passed a value from LocalState and an action to my dumb component through mantra container. The textfield’s value prop was the value from LS, the onChange was the action. The action simply updated the LocalState and an other LocalState for showing error messages. If the user changed the value in the textfield, react fired the action which updated the LS which updated the value of the TF - but because LS is asynchronous, the cursor in the TF jumped to the last position.
BTW, the second parameter for the callback function is the value. You can see it in the documentation at the bottom of this page for the “onChange” function signature.