Getting Started with React Native
Jun 26, 2017 am 10:53 AMMost people who are new to react native are deeply confused about this, so I will once again share an introductory article about react native
1: Props (property)
Most components can be customized using various parameters when they are created. These parameters used for customization are called props (properties). props are specified in the parent component, and once specified, they will not change during the life cycle of the specified component
Customized by using different properties in different scenarios , you can maximize the reuse scope of custom components. Just reference this.props in the render function and handle it as needed. Here is an example:
2: State (state)
We use two kinds of data to control a component:props and state. Props are specified in the parent component, and once specified, they will not change during the life cycle of the specified component. For data that needs to be changed, we need to use state.
Generally speaking, you need to initialize thestate in the constructor (Annotation: This is how ES6 is written, Many early ES5 examples used the getInitialState method to initialize the state, which will gradually be eliminated), and then call the setState method when modifications are needed.
Suppose we need to create a text that keeps flashing. The text content itself has been specified when the component is created, so the text content should be aprop. The display or hidden state of text (fast switching between display and concealment produces a flickering effect) changes over time, so this state should be written in state.
The above is the detailed content of Getting Started with React Native. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to build a real-time chat app with React and WebSocket

Guide to React front-end and back-end separation: How to achieve decoupling and independent deployment of front-end and back-end

How to build simple and easy-to-use web applications with React and Flask

How to build a reliable messaging app with React and RabbitMQ

How to build a fast data analysis application using React and Google BigQuery

React code debugging guide: How to quickly locate and solve front-end bugs

React Router User Guide: How to implement front-end routing control

How to package and deploy front-end applications using React and Docker
