Text strings must be rendered within a <Text> component when using touchableopacity

This is the code that is giving me this error and I cannot find a solution:

{ hasTracked ? null :
        <TouchableOpacity style={styles.button}> 
           <Text style={styles.buttonText}>Track data</Text>
        </TouchableOpacity>
}

>Solution :

Try this:

{!hasTracked &&
    < Pressable style={styles.button}> 
       <Text style={styles.buttonText}>Track data</Text>
    </Pressable >
}

Here is an example

Leave a Reply