Skip to content

Commit 425f2a4

Browse files
author
Huy Hoang Nguyen
authored
fix: override text on press props (#2)
1 parent 63c618c commit 425f2a4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ interface TokenProps {
2424

2525
interface AttributedTextProps extends TextProps {
2626
annotationProps?: {
27-
[key: string]: TextProps;
27+
[key: string]: TextProps & {
28+
onPress: (event: GestureResponderEvent & { content: string }) => void;
29+
};
2830
};
2931
children: string;
3032

@@ -77,9 +79,10 @@ const AttributedText = ({
7779
return (
7880
<Text
7981
{...tokenProps}
80-
onPress={(event: GestureResponderEvent) =>
81-
tokenProps.onPress({ ...event, content: token.content })
82-
}
82+
onPress={(event: GestureResponderEvent) => {
83+
tokenProps?.onPress &&
84+
tokenProps.onPress({ ...event, content: token.content });
85+
}}
8386
key={index}
8487
>
8588
{token.content}

0 commit comments

Comments
 (0)