Is there any built in text area component for react-native? I have tried to implement these ones:
https://github.com/buildo/react-autosize-textarea
https://github.com/andreypopp/react-textarea-autosize
but getting an error "Expected a component class got object object".
TextInput is a Core Component that allows the user to enter text. It has an onChangeText prop that takes a function to be called every time the text changed, and an onSubmitEditing prop that takes a function to be called when the text is submitted.
onSubmitEditing is triggered when you click the text input submit button (keyboard button). onChangeText is triggered when you type any symbol in the text input. In your example, you will achieve what you need in both cases. Save this answer.
TextInput basicsconst styles = StyleSheet. create({ input: { borderColor: "gray", width: "100%", borderWidth: 1, borderRadius: 10, padding: 10, }, }); In the piece of code above, we styled the text box's border and gave it some padding.
Yes there is. It's called TextInput, the normal TextInput Component supports multiple lines.
Just assign following properties to your TextInput Component
multiline = {true} numberOfLines = {4}
At the end you should have this:
<TextInput multiline={true} numberOfLines={4} onChangeText={(text) => this.setState({text})} value={this.state.text}/>
Source https://facebook.github.io/react-native/docs/textinput
If you want to see your TextInput
component like a textarea, you will need to add this
<TextInput multiline={true} numberOfLines={10} style={{ height:200, textAlignVertical: 'top',}}/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With