onContentSizeChange
doesn't seem to fire properly on Android. Event is fired on mount
, but isn't fired on text height
change. Identical code works fine for iOS:
<TextInput
editable = {true}
multiline = {true}
[...]
onContentSizeChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
style={{height: Math.max(35, this.state.height)}}
/>
https://github.com/facebook/react-native/issues/6552#issuecomment-269989962
In Android onContentSizeChange
is called only once
use onChange
instead of onContentSizeChange
.
Code
<TextInput
editable = {true}
multiline = {true}
[...]
onChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
style={{height: Math.max(35, this.state.height)}}
/>
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