Reactnative Study Notes (iv)--The life cycle of a component

Source: Internet
Author: User
Tags constructor

Today with Crazycodeboy Teacher's video (reactnative Basic and introductory tutorial) to learn, if you think watching video talk slow, wasting time, tune into 1.25 times times the speed of play can. Individuals have a bit of obsessive-compulsive disorder, want to learn more systematically, follow the video, you can also master some of the finer knowledge.

Summarize the main contents of today's study:

One, the life cycle of the component


Say a few more important ways:

Constructor (): The state is typically initialized in the constructor;

Componentdidmount (): This method is automatically called after the render () method, and network requests are typically placed in this method

Shouldcomponentupdate (): The method returns a Boolean value that determines whether the component needs to be re-rendered, returns True by default, and you can override this method yourself to determine whether you need to update the component by using a conditional judgment

Componentwillunmount (): Called before the component is removed, freeing some unwanted resources, such as stopping the timer

Second, learn 3 ways to define components

1,ES6 way definition, which is now the most common method, by inheriting the component, it is also recommended this method

2,ES5 way definition, see video is possible, but I wrote it myself, in the run times wrong, have not found the reason, so do not paste the code, I figured out after the supplement

3, defined by a functional method. The component defined in this way is stateless, that is, there is no state and this cannot be used because there is no this pointer. And because it's a function in itself, the component doesn't have a complete life-cycle approach


Reference:

React-native's React Tutorial-(middle)


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.