Today is my first day with gluestack, so I'm just playing around, but I ran into an issue:
The gluestack
<Text>
component throws an error in my web browser when I include the
onPress
prop:
Warning: Unknown event handler property `onPress`. It will be ignored.
What's interesting is that
onPress
works fine with React Native's
<Text>
element (see below)
Wrapping gluestack's
<Text>
in
<Pressable>
works fine, too.
Is this is a bug?
import { Fragment } from 'react';
import { Heading } from './ui/heading';
import { Text } from './ui/text';
import { VStack } from './ui/vstack';
import { Text as ReactNativeText } from 'react-native';
import { Pressable } from './ui/pressable';
function ListGroup() {
let items = [
'New York',
'Los Angeles',
'Chicago',
];
return (
<>
<VStack className="mx-2 rounded border border-b-0 border-gray-300">
{items.length === 0 && <Text>No Items</Text>}
{items.map((item) => (
<Fragment key={crypto.randomUUID()}>
<Text
key={crypto.randomUUID()}
onPress={() => console.log('pressed from text element')} // <<< This causes the error
className="select-none border-b-2 py-2 pl-4 text-orange-500"
>
{item}
</Text>
<Pressable onPress={() => console.log('pressed from pressable')}>
<Text
key={crypto.randomUUID()}
className="select-none border-b-2 py-2 pl-4 text-blue-500"
>
{item}
</Text>
</Pressable>
<ReactNativeText
onPress={() => console.log('pressedReactNative')}
key={crypto.randomUUID()}
className='select-none border-b-2 py-2 pl-4 text-green-500'
>
{item}
</ReactNativeText>
</Fragment>
))}
</VStack>
</>
);
}
export default ListGroup;