React.js Learning Route Six

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.