Does not parse html text
abdelwahed-mohamed opened this issue · 4 comments
Hello ,
I have a problem using this library with a html text string for example when my textToHightlight is a html string it does not get parsed i think the component should use the
https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
thank you in advance if anyone can point me on how to figure it out.
This component doesn't support markup. It's built to highlight plain text.
Sorry!
I’ve found just wrapping any text in the html with <Highlighter/>
works, although you have to keep passing around the searchWords, I think I’ll put in a PR to make a context manager for that prop for those cases.
@jstacoder
Looks like we can't.
<Highlighter
highlightClassName="YourHighlightClass"
searchWords={["the"]}
autoEscape={true}
>
<div dangerouslySetInnerHTML={{__html: note_Body}}/>
</Highlighter>
Failed prop type: The prop `textToHighlight` is marked as required in `Highlighter`, but its value is `undefined`.�
@AlexanderKozhevin the reason you are getting that error is because you did not pass it the textToHighlight
prop, which it still needs to know what its parsing through, (the error is very explicit). although im not sure it would work using dangerouslySetInnerHTML
anyway, you shouldnt use that, just make your html with jsx