0
I put a <TextInput/>
to do the search action on my project, but after I click on this <TextInput/>
, focus no longer leaves it, no matter where click on the screen, the function onBlur()
even runs and presents no error, even if I go to another page and return to the screen that has this <TextInput/>
, that bar that keeps blinking when we type, keeps blinking, I’ve tried to look for several examples of <TextInput/>
and they all present this same problem, it must be something very silly, but I can not solve it at all. Here’s the code I’m testing now.
import {
StatusBar,
View,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
SafeAreaView,
} from 'react-native';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
borderColor: '#fff',
};
}
onFocus() {
this.setState({
borderColor: '#000',
});
}
onBlur() {
this.setState({
borderColor: '#fff',
});
}
render() {
return (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: '#363A44',
alignItems: 'center',
}}>
<StatusBar
barStyle="light-content"
hidden={false}
backgroundColor="#000"
/>
<TextInput
onBlur={() => this.onBlur()}
onFocus={() => this.onFocus()}
style={{
height: 40,
width: 100,
borderWidth: 1,
borderColor: this.state.borderColor,
}}
/>
</View>
);
}
}
export default App;```
There is no error, as you say, in this code. https://snack.expo.io/@sant0will/a2e726
– sant0will
Open this link you sent me and put to run on Android, click on
TextInput
and then try to click out of it.– Alexsander Sarmento
all right, I get it
– sant0will