Skip to content

linkify-react with JSX input? #482

Answered by nfrasser
tordans asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @tordans, I suspect this doesn't work because the Nl2br component takes input as a prop, i.e., <Nl2br input={input} />. Linkify only attempts detecting links in text nodes, not in properties.

Have you tried the nl2br option for Linkify?
e.g.,

<Linkify options={{ nl2br: true }}>
    {input}
 </Linkify>

If you would prefer to use your Nl2br component, you could try re-writing it to accept its contents as children, i.e.,:

<Linkify>
    <Nl2br>{input}</Nl2br>
</Linkify>

But this would complicate your implementation because now you'd have to parse through a list of children, not all of which may be text nodes. Unless you plan to add other behaviour to your Nl2br component, Linkify's nl2br o…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tordans
Comment options

Answer selected by tordans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants