react-native-twitter-textview

<Text/> component for React Native and React Native Web that automatically detects #hashtags and @mentions.

code style: prettier

🚀 Getting Started

Using npm:

npm install --save react-native-twitter-textview

Using yarn:

yarn add react-native-twitter-textview

✍️ Usage

It’s super easy; just replace your React Native <Text /> component with a <TwitterTextView />, and there you go!

const App = () => {
  const [value, onChangeText] = useState('');
  return (
    <View
      style={StyleSheet.absoluteFill}
    >
      <TextInput
        onChangeText={onChangeText}
        value={value}
        placeholder="Type some #hashtags or @mentions to get started."
        multiline
        numberOfLines={4}
      />
      <TwitterTextView
        style={styles.twitterTextView}
        hashtagStyle={styles.hashtagStyle}
        mentionStyle={styles.mentionStyle}
        linkStyle={styles.linkStyle}
        emailStyle={styles.emailStyle}
      >
        {value}
      </TwitterTextView>
    </View>
  );
}

📋 Props


PropTypeDefaultRequiredDescription
childrenstringNoThe text to render.
extractHashtagsbooltrueNoWhether you wish to support hashtags.
onPressHashtagfunc(e, hashtag) => nullNoCalled when a detected hashtag is clicked.
hashtagStyleshape[object Object]styles.linkStyleNoHashtag style.
extractMentionsbooltrueNoWhether you wish to support mentions.
onPressMentionfunc(e, hashtag) => nullNoCalled when a detected mention is clicked.
mentionStyleshape[object Object]styles.linkStyleNoMention style.
extractLinksbooltrueNoWhether you wish to support links.
onPressLinkfunc(e, link) => Linking.openURL(link)NoCalled when a detected link is clicked.
linkStyleshape[object Object]styles.linkStyleNoLink style.
extractEmailsbooltrueNoWhether you wish to support emails.
onPressEmailfunc(e, link) => Linking.openURL(link)NoCalled when a detected email is clicked.
emailStyleshape[object Object]styles.linkStyleNoEmail style.

✌️ License

MIT

Buy @cawfree a coffee