React Native study notes, reactnative

Source: Internet
Author: User

React Native study notes, reactnative

React is a tool that uses ES6 and supports JSX syntax to develop componentized web or native. Now we use Babel to convert it into ES5 code.

The component passes unchanged content through the props attribute, and the UI changes through the state attribute.

React is an interface framework. Data management is troublesome and confusing in js. there is a redux library to manage a unified data storage point. an application has only one Store object and is a global variable that can be accessed everywhere.

 

Three Concepts of Redux:

Container, reduce, actions.

 

1. Create a container. The container is a concept that contains the business logic Code and is responsible for data display filtering and event binding. It is automatically created using connect.

Two methods are available: mapStateToProps and mapDispatchToProps. the last line of code connect (mapStateToProps, mapDispatchProps) (UIComponent) has two parentheses. The first one writes the two definition methods, the following brackets indicate the UI component class in which the props should be used.

 

2. reduce is a function that can pass two parameters (state, action) and return the changed state. the core concept is not to directly modify the state value through the Object. assign ({}, state, {New Value Attribute keyvalue} to be overwritten) to create a new object and return.

3. actions is a number of functions that indicate the action to be executed. The method name can be defined as addNews, listNews, and delNews. Actually, A {key: "ADD_NEWS", "other" is returned directly ": "dfdsfdsf"}, in addition to the key, you can define the parameters required to pass to the event processing.

 

4. How to trigger action?

Triggered by using the global method dispatch (action, custom parameter.

 

5. It is best to write events in components as closure. Other forms may not find methods or the like. The principle is that this is not caused by this.

Closure statement:

Var clickGetUserInfo = (id) => {

This. refs. uiEle. text = "23421323"

}

 

Render (){

<View onClick = {clickGetUserInfo} ref = "uiEle">

}

 

Related Article

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.