react-linkify
react-linkify copied to clipboard
Does not work with dangerouslySetInnerHTML
Hello! I ran into this bug while using the library. Linkify
does not work when wrapping a component that's created with dangerouslySetInnerHTML
. The use-case for that is to generate templates (e.g. blog posts) that was saved in a database.
// This identifies the URI and wraps it with an anchor text
<Linkify>
<p>
<span>Go to https://google.com</span>
</p>
</Linkify>
// This did not catch the link
<Linkify>
<p dangerouslySetInnerHTML={{ __html: '<span>Go to https://google.com</span>'}} />
</Linkify>
It's a pretty easy fix, the parse function just has to check dangerouslySetInnerHTML.__html
as well as children, but this repo seems fairly dead.
Any updates on this issue?
Any update on this issue?
The is the work around and it worked just fine for me.
dangerouslySetInnerHTML={{ __html: ReactDOMServer.renderToString(<Linkify><span>Go to https://google.com</span></Linkify>) }}