tasti / react-linkify

React component to parse links (urls, emails, etc.) in text into clickable links
http://tasti.github.io/react-linkify/
MIT License
555 stars 106 forks source link

Suggestion: add option to set text using property dangerouslySetInnerHTML. #49

Closed oztek22 closed 6 years ago

oztek22 commented 7 years ago

In render of Linkify.jsx, you can replace return code with this line to add supports to HTML tags. <span className={this.props.className} dangerouslySetInnerHTML={{ __html: parsedChildren }}></span>

tasti commented 6 years ago

Support for dangerouslySetInnerHTML was intentionally left out since it's, you know, dangerous.

If you have text that contains HTML tags that you also want to linkify, you can do so by first running it through dangerouslySetInnerHTML, and then using Linkify on the result. For example:

<Linkify>
  <span dangerouslySetInnerHTML={{__html: text}}></span>
</Linkify>
BrodaNoel commented 5 years ago

@tasti not sure why, but that actually doesn't work.

I have this:

<Linkify>
  <p className="col-md-7" dangerouslySetInnerHTML={{ __html: description }} />
</Linkify>

And it renders:

<span class="Linkify">
  <p class="col-md-7">
    <p>blablabla https://google.com google.com asdasd</p>
  </p>
</span>

The content of decription is: <p>blablabla https://google.com google.com asdasd</p>

ricardosouza-logmein commented 3 months ago

this issue should not be closed, this ticket still valid IMO