react-native-parsed-text icon indicating copy to clipboard operation
react-native-parsed-text copied to clipboard

Multiple hashtags

Open andrefangeloni opened this issue 4 years ago • 1 comments

Hi there, When the text has multiple hashtag, how could I know witch of them was pressed? e.g: Nice job! #foo #bar

I'd like to do a feature likes Instagram, search for specific hashtag, but onPress is generic. Thanks

andrefangeloni avatar Jan 27 '21 04:01 andrefangeloni

pattern:

{
  pattern: /#[^\s!@#$%^&*()=+./,\[{\]};:'"?><،؛؟-]+/gi,
  style: [_linkStyle, linkStyle, boldFont],
  onPress: handleHashtagPress,
}

on press hashtag:

const handleHashtagPress = (value, matchIndex) => {
  navigation.push('Posts', {
    hashtag: {text: value.slice(1)}, // value.slice(1): value without # sign
  });
};

ameer-taghavi avatar Sep 14 '21 07:09 ameer-taghavi