mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-04 21:09:21 +08:00
Docs: Basic Components Update
Summary: This is an improvement to basic components docs. * I updated the basic components example code to better render components on iOS (added paddingTop). * I also modified the code to allow reader to easily copy, paste, and then run the code in their project if they followed the 'Getting Started' quick start guide. * I also added additional copy to clarify suggested usage/guidelines. Closes https://github.com/facebook/react-native/pull/8292 Differential Revision: D3469943 Pulled By: JoelMarcey fbshipit-source-id: 21ff6ee13b59741c43d80aab68a38aace0fbfca6
This commit is contained in:
committed by
Facebook Github Bot 6
parent
109e3d79cc
commit
4243d682a0
@@ -9,20 +9,29 @@ next: basics-component-scrollview
|
||||
|
||||
Direct text-based user input is a foundation for many apps. Writing a post or comment on a page is a canonical example of this. [`TextInput`](/react-native/docs/textinput.html#content) is a basic component that allows the user to enter text.
|
||||
|
||||
This example creates a simple `TextInput` box with the `string` `Hello` as the placeholder when the `TextInput` is empty.
|
||||
This example creates a simple `TextInput` box with the `string` `Type something here` as the placeholder when the `TextInput` is empty.
|
||||
|
||||
```JavaScript
|
||||
import React from 'react';
|
||||
import { AppRegistry, TextInput, View } from 'react-native';
|
||||
import { AppRegistry, Text, TextInput, View } from 'react-native';
|
||||
|
||||
const App = () => {
|
||||
const AwesomeProject = () => {
|
||||
return (
|
||||
<View>
|
||||
<TextInput placeholder="Hello" />
|
||||
</View>
|
||||
<View style={{paddingTop: 22}}>
|
||||
<TextInput
|
||||
style={{
|
||||
height: 40,
|
||||
margin: 5,
|
||||
paddingLeft: 10,
|
||||
borderColor: 'black',
|
||||
borderWidth: 1
|
||||
}}
|
||||
placeholder="Type something here"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
// App registration and rendering
|
||||
AppRegistry.registerComponent('MyApp', () => App);
|
||||
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user