stef000
stef000

Reputation: 123

Expo import of Pressable throws invariant violation error

I am developing an app using expo and was trying to style my button. However, it was suggested in another stack overflow question to switch to TouchableOpacity and on the react-native TouchableOpacity page they suggest to switch to a future proof solution called Pressable. Now I am trying to implement the Pressable component in my component like they have on the react-native Pressable page and my code looks like this:

import { View, Text, Button, Pressable } from 'react-native';

export default function OrderDetail( {someProps} ){
.
.
.
<Pressable
    onPress={() => {
    setCategoryName('information')
    }}
    style={({ pressed }) => [
    {
        backgroundColor: pressed
        ? 'rgb(210, 230, 255)'
        : 'white'
    },
    styles.wrapperCustom
    ]}>
    {({ pressed }) => (
    <Text style={styles.text}>
        {pressed ? 'Pressed!' : 'Press Me'}
    </Text>
    )}
</Pressable>
.
.
.
}

but I am getting this error:the thrown error message

Upvotes: 2

Views: 786

Answers (1)

Steven Bell
Steven Bell

Reputation: 1989

Pressable is not available in Expo yet, because expo does not support React Native v0.63 (yet).

Upvotes: 4

Related Questions