bvaughn / react-highlight-words

React component to highlight words within a larger body of text
https://bvaughn.github.io/react-highlight-words/
MIT License
2.16k stars 170 forks source link

Should accept regular expression as element in searchWords array #29

Closed rayshan closed 7 years ago

rayshan commented 7 years ago

Hi, thanks so much for this library. I try to pass [new RegExp(\b(${myVariable})\b, 'i')] to searchWords. It works fine but produces below warning:

Warning: Failed prop type: Invalid prop `searchWords[0]` of type `regexp` supplied to `Highlighter`, expected `string`.
bvaughn commented 7 years ago

This isn't how the library works. 😄 You pass it an array of strings and it converts them to regular expressions.

If you feel the component should work differently, I'd be happy to review a PR. 😁 Otherwise I think it's fine as-is.