Reputation: 89
I need your help. I created a standalone component, that I import in my main component. But when I trying to run my app I see an error "Cannot read property createElement of 'undefined'". Red arrow points on TouchableOpacity in my component. What is my problem? Thanks a lot
import { React } from 'react'
import { TouchableOpacity, View, Text, StyleSheet } from 'react-native'
const MyButton = ({ name, onPress }) => {
const { container, text } = styles;
return (
<TouchableOpacity onPress={onPress}>
<View style={container}>
<Text style={text}>{name}</Text>
</View>
</TouchableOpacity>
)
}
const styles = StyleSheet.create({
container: {
width: 250,
height: 30,
backgroundColor: 'aqua',
alignSelf: 'center'
},
text: {
color: 'white',
fontSize: 30
}
})
export { MyButton }
Upvotes: 0
Views: 198