Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  17] [ 2]  / answers: 1 / hits: 22033  / 9 Years ago, wed, october 14, 2015, 12:00:00

I am dynamically creating multiple text inputs (with dynamically created refs) along side the text that I want updated with the input.



I am trying to get the value of the input by setting the ref to a variable and finding the DOM node with React.findDOMNode(this.refs.Variable).value



I am getting a Cannot read property 'value' of null error.



How can I achieve this?



This is what the function looks like:



resetUnit: function(e){
var refID = e.target.id;
var ID = refID.split(-)[0];
var Value = React.findDOMNode(this.refs.refID).value;
NodesCollection.update({_id: ID},{$set: { materialUnit : Value}});
this.setState({
edit: ''
});
},

More From » meteor

 Answers
13
var Value = React.findDOMNode(this.refs.refID).value;


finds the DOM node for the component with the ref refID. If you want to find the DOM node for the component with the ref refID (the variable), you need



var Value = ReactDOM.findDOMNode(this.refs[refID]).value;

[#64751] Saturday, October 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dustin

Total Points: 599
Total Questions: 105
Total Answers: 106

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
dustin questions
;