React Native Use problem record

Source: Internet
Author: User



There is a space between 1.<view></view> error Trying to add unknown View tag




2. Some JS syntax sugar attention points
Http://facebook.github.io/react-native/docs/javascript-environment.html#content
Function-expression Syntax:
() =>xxx equals function () {return xxx;}
Function-expression Syntax:
State={a:1,b:2,c:3}
... state equals



3. Component Onpress Event parameters
Parameter Type Respondersyntheticevent
may get coordinate information structure {identifier,timestamp,locationy, locationx,pagex,pagey,target} via E.nativeevent
Target is a number.



4. Component OnLayout Event parameters
Parameter Type Syntheticevent
Coordinate information structure may be obtained by e.nativeevent.layout {height, width, y.5, x}






5. A component that refers to the JS pair image bug


<View style = {[styles.circle, this._circleStyles]} />

// The style cannot be obtained in this way
this._circleStyles.left = this._previousLeft + gestureState.dx;
this._circleStyles.top = this._previousTop + gestureState.dy;

// You can use this

this._circleStyles = {
left: this._previousLeft + gestureState.dx,
top: this._previousTop + gestureState.dy
};





6.ref and refs
The label generated by render in the component can be set by using the Ref attribute for the field name. The corresponding label can be referenced in the component by this.refs[' myrefstring ') or this.refs.myRefString





render: function () {
return <Text ref = "myInput" />;
},
componentDidMount: function () {
this.refs [‘myInput‘]
this.refs.myInput
}

// ref can also be used as a callback function, the callback parameter is the label reference
render: function () {
return <Text ref = {(c) => this._input = c} />;
},
componentDidMount: function () {
this._input.focus ();
} 














React Native Use problem record


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.