Skip to content

Commit

Permalink
update TextInput example, refs facebook#2187
Browse files Browse the repository at this point in the history
  • Loading branch information
Simek authored Sep 1, 2020
1 parent 0749856 commit 5a72cc4
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions docs/textinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@ A foundational component for inputting text into the app via a keyboard. Props p
The most basic use case is to plop down a `TextInput` and subscribe to the `onChangeText` events to read the user input. There are also other events, such as `onSubmitEditing` and `onFocus` that can be subscribed to. A minimal example:

```SnackPlayer name=TextInput
import React, { Component } from 'react';
import { TextInput } from 'react-native';
import React from "react";
import { SafeAreaView, StyleSheet, TextInput } from "react-native";
const UselessTextInput = () => {
const [value, onChangeText] = React.useState('Useless Placeholder');
const [text, onChangeText] = React.useState("Useless Text");
const [number, onChangeNumber] = React.useState(null);
return (
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
onChangeText={text => onChangeText(text)}
value={value}
/>
<SafeAreaView>
<TextInput
style={styles.input}
onChangeText={onChangeText}
value={text}
/>
<TextInput
style={styles.input}
onChangeText={onChangeNumber}
value={number}
placeholder="useless placeholder"
keyboardType="numeric"
/>
</SafeAreaView>
);
}
};
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
},
});
export default UselessTextInput;
```
Expand Down

0 comments on commit 5a72cc4

Please sign in to comment.