I have a TextInput component that should transform the input to capitals whilst typing. My code is as follows:
import React, {Component} from 'react';
import { View, StyleSheet, Text, TextInput, Button } from 'react-native';
export default class ProfileTest extends React.Component {
constructor(props) {
super(props);
this.state = {text : ''};
}
render() {
return (
<View>
<TextInput
style={{fontSize : 60}}
onChangeText={text => {
text = text
.toUpperCase();
this.setState({ text: text });
}}
value={this.state.text}
placeholder="enter text"
/>
</View>
)
}
}
And on Expo, this does work. However, when I try this on my Android device, I get the following behavior:
The first two letters work fine, but whenever I add a third letter, it suddenly repeats the first two letters so that ABC -> ABABC I have no idea why it does this and I cannot seem to get rid of it. I have identified the '.toUpperCase()' as the culprit.
Thanks for helping!