2017-06-12 105 views
1

我在Android設備上的TextInput事件'onContentSizeChange'出現問題。 實際上,當我輸入消息直到行尾並且文本進入下一行時,TextInput的高度不會更新。React Native:TextInput元素上的onContentSizeChange事件在Android上不起作用

例如:

return (
     <TextInput 
     {...this.props} 
     multiline={Boolean(true)} 
     onChangeText={(text) => { 
      this.setState({text}) 
     }} 
     onContentSizeChange={(event) => { 
      this.setState({height: event.nativeEvent.contentSize.height}) 
     }} 
     style={[ additionalStyles, {height: this.state.height}, {fontSize: config.defaultFontSize} ]} 
     value={this.state.text} 
     underlineColorAndroid={'rgba(0,0,0,0)'} 
     /> 
    ) 

有誰知道爲什麼它可偏偏?

P.S.幫助使用onChange而不是onContentSizeChange

回答

1

請參閱React Native issue #11692。這看起來將在即將發佈的版本中得到修復。目前尚不清楚,它只是在幾周前被修復,但也許會在0.46。

+0

幫助使用onChange而不是onContentSizeChange,謝謝! – Dmitry

相關問題