'React Native Expo Screen Touch Not Registering
I am in the process of developing an app using React Native and yesterday all touchable objects seemed to stop responding.
The last changes were made to an AppNavigator component but after taking it all apart I do not think that's the root cause.
I have stripped the code down to the bare bones (also removing the above component) to try to get a simple TouchableOpacity to respond but with no luck.
These are the current dependency versions (Only the ones I thought might be relevant) and below is the entire app code:
- expo 44.0.0
- react 17.0.1
- react-native 0.64.3
- react-redux ^7.2.6
- redux ^4.1.2
- redux-persist ^6.0.0
- redux-thunk ^2.4.1
- Running Expo GO on iPhone with iOS 15.4.1
None of these items have changed in the interim of it working -> not working though
import React from 'react'
import {View, StyleSheet, Text,TouchableOpacity,} from 'react-native'
import { NavigationContainer } from '@react-navigation/native';
import {Provider} from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import {store, persistor} from './redux/store'
export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<NavigationContainer>
<View style={styles.container}>
<TouchableOpacity style={styles.press} onPress={()=>{console.log("PRESSED!")}}>
<Text>Press me!</Text>
</TouchableOpacity>
</View>
</NavigationContainer>
</PersistGate>
</Provider>
)
}
}
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
alignItems: 'center',
flex: 1,
position: 'relative'
},
press:{
borderWidth:1,
height: 100,
width: 100,
},
})
I have stripped it down when I tried to debug but I still do not get any response from the onPress.
Original issue contained a TextInput field which was the only responsive thing on the screen. When pressed, it allowed text to be filled in, but I later placed a console.log() within the "onChangeText" function and that never fired so not sure how the text updated in the first place...
Not sure if that helps debugging, but to me that might suggest something is running in the background and blocking a thread?
Any idea what might be blocking the responsiveness?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
