Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28479

How to correctly trim user input in React Native?

$
0
0

I have TextInput that receives onChangeText as a prop:

<TextInput
  ...
  value={this.state.myString}
  onChangeText={this.updateInput.bind(this)}
/>

And updateInput is represented as:

updateInput(newString) {
  this.setState({ myString: newString.trim() });
}

This works for Android only. Is there some way to trim user input on both platforms (iOS, Android)?

Update

Actually, string is processed as trimmed, but you can still type as many whitespaces as you want on iOS. And if you type two whitespaces in a row the dot appears like it would be the end of the sentence. This is undesirable behaviour, is there a way to avoid it?

Link with example video: https://streamable.com/dzl3c


Viewing all articles
Browse latest Browse all 28479

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>