Closed camden closed 7 years ago
Hi @camden. Sorry for somehow missing this PR. This isn't a super active project for me and...it happens.
I'm not a huge fan of the fact that this change would expand the API to define both a highlightTag
(eg "div") and what is essentially a render-prop for highlights. These 2 strongly overlap.
I propose (and will go ahead and make this change for 0.9.0, which I'll be releasing momentarily) changing the highlightTag
param to accept React elements in addition to strings. Then you can pass in:
const HighlightTag = ({ children, ...rest }) => (
<div
onClick={doSomething}
{...rest /* className, style, etc */}
>
{children}
</div>
)
Looks great. Thanks @bvaughn !
You're welcome 😄
For example, we can pass in the following function:
This would enable custom behavior to be added to highlighted words.