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)