The stringReplaceJsx
method returns a new string with some or all matches of a pattern.
npm i --save string-replace-jsx
import stringReplaceJsx from "string-replace-jsx";
<div>
{stringReplaceJsx("fuga https://google.com", urlRegex, (match) => (
<a
className={styles.link}
href={match.toString()}
target="_blank"
rel="noreferrer"
>
{match}
</a>
))}
</div>;