In learning react, I always thought that there was a constructor in the total component, but I realized that my view was wrong and that the constructor could be inside the subassembly.
One mistake today is to click the value in the Add/decrease input box.
I've been looking for values in the input box, which is the value, and I've found that my thinking is completely wrong. React is only view, is unable to manipulate the data, can only render the original data changes, in other words, I want to change the value, can only change the original data inside the values, and then re-render into the input box.
My raw data, gave
Value:1;
When clicked, the constructor
Add (e) {
var num = This.state.value; First get the original value
num + +; I give the original value each time I click, add 1
This.setstate ({//re-render data
Value:num
})
}
That is to say, I did not get the value in the input box, the value inside the input box is rendered, and I changed the original value.
So, my later thinking to change, I do not get anything inside the DOM component, the results of the page are rendered from the original data. So, when I want to modify this data, don't think about how to change the value of these tags, but to change from the original data
React.js Learning Route Six