mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-29 22:41:56 +08:00
Summary: > ListView is not supported by React Native Web as of yet, so it will not have it. Closes https://github.com/facebook/react-native/pull/8331 Differential Revision: D3472019 Pulled By: lacker fbshipit-source-id: e5fb430b6c8f4d437943c159beb00b9d9252c92d
1.4 KiB
1.4 KiB
id, title, layout, category, permalink, next
| id | title | layout | category | permalink | next |
|---|---|---|---|---|---|
| basics-component-text | Text | docs | The Basics | docs/basics-component-text.html | basics-component-image |
The most basic component in React Native is the Text component. The Text component simply renders text.
This example displays the string "Hello World!" on the device.
import React from 'react';
import { AppRegistry, Text } from 'react-native';
const AwesomeProject = () => {
return (
<Text style={{marginTop: 22}}>Hello World!</Text>
);
}
// App registration and rendering
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
In this slightly more advanced example we will display the string "Hello World" retrieved from this.state on the device and stored in the text variable. The value of the text variable is rendered by using {text}.
import React from 'react';
import { AppRegistry, Text } from 'react-native';
var AwesomeProject = React.createClass({
getInitialState: function() {
return {text: "Hello World"};
},
render: function() {
var text = this.state.text;
return (
<Text style={{marginTop: 22}}>
{text}
</Text>
);
}
});
// App registration and rendering
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);