Ad
React Native Alert Function
I want to show the alert function when I press the continue button. But I have an error. I want to put an alert function inside my onPress touchableOpacity. This is my code.
export default class Rate extends Component {
render() {
}
return (
<TouchableOpacity
activeOpacity={0.7}
style={styles.button}
onPress={() =>
firebase.database().ref(list.title).set({Ratings : (this.state.Default_Rating)})
alert('Thank you')
}>
<Text>Continue</Text>
</TouchableOpacity>
</View>
); }}
Ad
Answer
Your render method should be like as below and add one more bracket in onPress of TouchableOpacity
render() {
return (
<TouchableOpacity
activeOpacity={0.7}
style={styles.button}
onPress={() => {
firebase.database().ref(list.title).set({Ratings :
(this.state.Default_Rating)})
alert('Thank you')
}
}>
<Text>Continue</Text>
</TouchableOpacity>
);
}
Ad
source: stackoverflow.com
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?
Ad