Im an working on React Native application. I have two different screens, Login and Register. Both the components are present in different modules. But, when I add onPress prop to the button in one screen, it is affecting the other screen also. For ex, if I click button of login screen, it is calling function of register screen, even there is no such event added for login screen button.
Please look at the code blocks,
LoginForm.js
<TouchableOpacity style={styles.buttonContainerRegister} onPress = {() => this.props.navigation.navigate('RegisterScreen')}>
<Text style={styles.buttonText}>REGISTER</Text>
</TouchableOpacity>
RegisterForm.js
<TouchableOpacity style={styles.buttonContainerRegister1} testID="test1" >
<Text style={styles.buttonText1} onPress = {Alert.alert("my")} >Register</Text>
</TouchableOpacity>
When I click button of LoginForm.js, it is triggering event add for RegisterForm.js button.