mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 09:35:48 +00:00
f2affcf24d
Summary: Will create new issue to add more information to the `Components` section of the Tutorial since that was gutted by this change. Fixes #8156 Closes https://github.com/facebook/react-native/pull/8256 Differential Revision: D3459601 Pulled By: JoelMarcey fbshipit-source-id: 4038afc463bffcf8efda36d29bc7c443bbc8f4bd
1.2 KiB
1.2 KiB
id | title | layout | category | permalink | next |
---|---|---|---|---|---|
basics-component-view | View | docs | Basics | docs/basics-component-view.html | basics-component-textinput |
A View
is the most basic building block for a React Native application. The View
is an abstraction on top of the target platform's native equivalent, such as iOS's UIView
.
A
View
is analogous to using adiv
for building websites.
While basic components such as Text
and Image
, can be displayed without a View
, this is not generally recommended since the View
gives you the control for styling and layout of those components.
This example creates a View
that aligns the string
Hello
in the top center of the device, something which could not be done with a Text
component alone (i.e., a Text
component without a View
would place the string
in a fixed location in the upper corner):
import React from 'react';
import { AppRegistry, Text, View } from 'react-native';
const App = () => {
return (
<View style={{alignItems: 'center'}}>
<Text>Hello!</Text>
</View>
);
}
// App registration and rendering
AppRegistry.registerComponent('MyApp', () => App);