Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not correctly searching in nested elements #30

Open
McPo opened this issue Oct 25, 2016 · 3 comments
Open

Not correctly searching in nested elements #30

McPo opened this issue Oct 25, 2016 · 3 comments

Comments

@McPo
Copy link

McPo commented Oct 25, 2016

Im attempting to use react-linkify with react-highlight-words (https://github.com/bvaughn/react-highlight-words/blob/master/src/Highlighter.js)

However it appears linkify is not finding the text.

<Linkify properties={ { target: '_blank' } }><Highlighter searchWords={ this.props.highlight } textToHighlight={ msg.body }>{ msg.body }</Highlighter></Linkify>

Its not an issue with the resulting DOM, as mimicking the DOM as input still works.

<Linkify properties={ { target: '_blank' } }><span><span>{ msg.body }</span></span></Linkify>

It appears to be caused by the fact that react-highlight doesn't place the text as a child, but a prop instead.

@McPo
Copy link
Author

McPo commented Oct 25, 2016

I ended up moving to https://www.npmjs.com/package/react-highlighter instead, which uses child props for the main text (I didn't use it initially as I wasn't aware that it supported RegExp), and all works fine.

Maybe make a note regarding it only searches child props?

@mhemrg
Copy link

mhemrg commented Dec 3, 2019

#78 (comment)

@AHTHneeuhl
Copy link

import Linkify  from "react-linkify";
import Highlight from "react-highlighter";

<Linkify>
  <Highlight search={keywords}>{text}</Highlight>
</Linkify>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants