0

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 }
1
  • can you show us your main component ? Commented Jun 27, 2021 at 12:11

1 Answer 1

2

You should import React this way : import React from 'react';

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.