Once your development environment is ready, it's time to write some real applications. As mentioned before, React native is really just React, but there are a few differences. The React native component looks more like a React component for a browser, but your basic building blocks have changed, such as a Div, IMG, or a label like P. React Native provides you with basic components such as text or view, and in the following example, the basic components ScrollView, touchablehighliht, and text components are used, all of which will be mapped to the Android and iOS-specified view. Using them to create a scrolling view, along with the appropriate touch processing, is straightforward:
var React = require (' react-native ');
var {ScrollView, touchablehighlight, Text} = React;
var Touchdemo = React.createclass ({
Render:function () {
return (
<ScrollView>
<touchabl Ehighlight onpress={() = Console.log (' pressed ')}>
<text>proper Touch handling</text>
</ touchablehighlight>
</ScrollView>
);
},
});
If you have not handled the syntax of HTML and JavaScript, it seems a bit confusing, react strongly suggest you use JSX, for react Native, you have no choice. The decoration of your rendering, which is used in conjunction with JavaScript to control its behavior, is often subject to strong opposition from the novice. But I strongly suggest you give it a chance.
Because the react native component is very similar to the react component, it is also very easy to convert react to react native.