This site article is Li Himi original, reproduced must be clearly noted:
Reprinted from "Black Rice gamedev Block" original link: http://www.himigame.com/react-native/2242.html
The development of the game should be very clear, "brush screen" is how important. In fact, the development of the application is also the case, when the data of the component is modified, how to update the component to present the latest data and effect is just as important.
So here Himi about three common ways: this.setstate () "most commonly used"
This is the primary method of triggering UI updates in the event handler and in the request callback function.
In general, SetState () always triggers a redraw unless conditional rendering logic is implemented in Shouldcomponentupdate (). If you use mutable objects, but you cannot implement this logic in Shouldcomponentupdate (), you can avoid unnecessary re-rendering by calling SetState () only when there is a difference between the new state and the previous state.
For example, the code snippet is as follows:
1 2 3 4 5 6 7 8 9-one for each of the ten, and the same. |
cons Tructor (props) {super (props); state = { & nbsp; myName: ' I am myname! ',}; } Testfun () { this. setState ({myName: ' component is refreshed '});} Render () { ... < touchablehighlight Underlaycolor = ' #4169e1 ' onpress = {this. testfun. Bind ( |
/table>