Reputation: 976
I've actually a TextInput like that :
<TextInput
onChange={(event) => {
this.setState({
text: event.nativeEvent.text,
height: event.nativeEvent.contentSize.height,
});
}}
editable={!this.state.load}
style={{height: this.state.inputFocused == true || this.state.text.length > 0 || this.state.picture.uri != undefined ? Math.max(height / 11.8, this.state.height) : height / 2.5, width: width, backgroundColor: 'white', fontFamily: 'Aller', fontSize: width / 24, padding: width / 38, alignItems: 'flex-start', justifyContent: 'flex-start', textAlignVertical: 'top',}}
multiline={true}
value={this.state.text}
/>
I'm using this TextInput to add content but also to edit, so I initialize class that uses it with default value in TextInput and height And the height of the textInput does not automatically adjust as I would like.
So how can I do to get height occupied by the text in a textInput without using any event ?
Upvotes: 4
Views: 265
Reputation: 502
just do not give it a height style, so it will not get any height and match its content height
Upvotes: 1