react-native/docs/Basics-Component-Text.md
Joel Marcey d464f1d1c2 Add React Native Web Player to most component basics
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
2016-06-22 15:13:32 -07:00

52 lines
1.4 KiB
Markdown

---
id: basics-component-text
title: Text
layout: docs
category: The Basics
permalink: docs/basics-component-text.html
next: basics-component-image
---
The most basic component in React Native is the [`Text`](/react-native/docs/text.html#content) component. The `Text` component simply renders text.
This example displays the `string` `"Hello World!"` on the device.
```ReactNativeWebPlayer
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}`.
```ReactNativeWebPlayer
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);
```