TouchableHighlight activates wrong button when next to each other
See original GitHub issue- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
React Native Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 838.79 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.11.1 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.1 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
IDEs:
Xcode: 9.4/9F1027a - /usr/bin/xcodebuild
npmPackages:
react: ^16.5.0 => 16.5.0
react-native: ^0.57.1 => 0.57.1
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Description
I have a React-Native view where I have to buttons side by side from each other.
What is happening is when I click Back, it does what it is supposed to do: console.log(-1)
However, when I click on Next, the console.log
of “Back” is being activated almost 70% of the time and only 30% of the time it shows a console.log(+1)
I have no idea why this is happening. Here is a screenshot of what is rendered. Left side is what you see from the code below and the right side is what you see if I add a red border to styles.footerButtonContainer
.
footerButtonContainer: {
flex: 1,
flexWrap: 'wrap',
alignItems: 'flex-start',
justifyContent: 'center',
flexDirection:'row',
borderWidth:1,
borderColor:"red"
},
What is even weirder is, if I add this border, then the above issue completely disappears and the buttons act as they are supposed do.
Reproducible Demo
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: "#ecf0f1",
paddingBottom:30
},
footer: {
position: 'absolute',
left: 0,
bottom: 0,
width:"100%",
height:55,
backgroundColor:"#fff",
},
footerButtonContainer: {
flex: 1,
flexWrap: 'wrap',
alignItems: 'flex-start',
justifyContent: 'center',
flexDirection:'row',
},
footerItem: {
flex:1,
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'center',
flexDirection:'row',
borderWidth:1,
borderColor:"#F1F0F4",
height:55,
width:"100%"
},
footerIcon: { marginTop:-5 },
footerText: { marginTop:-5, textAlign:"center", fontSize:24, fontWeight:"400", color:"#6B6D77", borderWidth:0, borderColor:"red" }
});
render() {
return (
<View style={{ height:"100%" }}>
<ScrollView ref="scrollWindow" style={{ paddingTop:"5%", marginBottom:56}}>
<View style={styles.container}>
</View>
</ScrollView>
<View style={styles.footer}>
<View style={{height:5, backgroundColor:"#E8E8EA", width: "25%"}} />
<View style={styles.footerButtonContainer}>
<TouchableHighlight underlayColor='#fff' style={styles.footerButtonContainer} onPress={() => {
console.log("-1");
} }>
<View style={styles.footerItem}>
<Icon containerStyle={styles.footerIcon} name="chevron-left" color="#000" type="solid" size={24} />
<Text style={[styles.footerText, {marginLeft: 10}]}>Back</Text>
</View>
</TouchableHighlight>
<TouchableHighlight underlayColor='#fff' style={styles.footerButtonContainer} onPress={() => {
console.log("+1");
}}>
<View style={styles.footerItem}>
<Text style={[styles.footerText, {marginRight: 10, color:"#000"}]}>Next</Text>
<Icon containerStyle={styles.footerIcon} name="chevron-right" color="#000" type="solid" size={24} />
</View>
</TouchableHighlight>
</View>
</View>
);
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:17
Top Results From Across the Web
React-Native TouchableHighlight activates wrong button ...
I have a React-Native view where I have to buttons side by side from each other. What is ...
Read more >React Native touchable vs. pressable components
Learn the difference between touchable and pressable components in React Native, and how to implement different effects with each kind.
Read more >TouchableHighlight - React Native
A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, which allows the...
Read more >Click Events - Buttons - JavaScript Camp
Click Events - Buttons. A surface on the screen that is clicked as an event that triggers a response from the associated action....
Read more >Accessibility · React Native
For example, a selected row in a table or a selected button within a segmented control. plays Used when the element plays its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can add the following info’s:
Closing since this seems to be fixed in the latest RN version.