const renderTextWithLinks = (text: string): React.ReactNode => {
const allWords = text.split(' ');
return allWords.flatMap((word, index) => {
if (isEmail.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(`mailto:${word}`)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
if (isPhoneNumber.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(`tel:${word}`)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
if (isUrl.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(word)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
return `${word} `;
});
};
const renderTextWithLinks = (text: string): React.ReactNode => {
const allWords = text.split(' ');
return allWords.flatMap((word, index) => {
if (isEmail.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(`mailto:${word}`)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
if (isPhoneNumber.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(`tel:${word}`)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
if (isUrl.test(word)) {
return (
<TextRN key={index} onPress={() => Linking.openURL(word)} style={styles.underlineText}>
{`${word} `}
</TextRN>
);
}
return `${word} `;
});
};