Reputation: 515
I have a problem with the react-native buttons. When I test them in a newly initialized project, everything works fine. But when I want to implement them into my project, it does not work and it gives me an error...
This here is a part of my project (not important stuff has been left out):
import React from 'react';
import {
Platform,
StyleSheet,
TouchableOpacity,
View,
Image,
Text,
Button,
Alert
} from 'react-native';
export default class CustomButtons extends React.Component {
constructor(props) {
super(props);
}
onPressLearnMore(){
Alert.alert("WORKING");
}
render(){
return(
<Button
onPress={this.onPressLearnMore()}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
);
}
}
I´ve been reading about solutions, where the import of the Button was not correct, I don't see anything wrong with mine though. An help would be great!
Upvotes: 1
Views: 1319
Reputation: 35890
The Button
component was added to React Native 0.37. You are probably using an older version.
Upvotes: 2