sindresorhus / linkify-urls

Linkify URLs in a string
MIT License
160 stars 22 forks source link

Output React component #38

Open fregante opened 1 year ago

fregante commented 1 year ago
import {LinkifyUrls} from "linkify-urls/react"

<LinkifyUrls
    string='a string with https://example.com'
    target="_blank"
/>

Does it make sense as part of this module? The current solution:

<div
  dangerouslySetInnerHTML={{
    __html: linkifyUrls('a string with https://example.com', {
      attributes: {
        target: "_blank",
      },
    }),
  }}
></div>

React does not accept DocumentFragment and other raw elements.

sindresorhus commented 1 year ago

Sure