-
Notifications
You must be signed in to change notification settings - Fork 581
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
Added a render prop to Mention component for custom rendering the display value #502
base: master
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/signavio/react-mentions/ApJRr7Y36K1aDsgrdEYuXew9ASM6 |
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
- Coverage 78.84% 78.76% -0.09%
==========================================
Files 32 32
Lines 695 697 +2
Branches 108 109 +1
==========================================
+ Hits 548 549 +1
- Misses 146 147 +1
Partials 1 1
Continue to review full report at Codecov.
|
This would be a much needed addition for my needs as well! |
8265bf0
to
8dedc5d
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I would love this as well. |
was this merged yet? i also want this as well |
Any update? |
Really need support for this, can we get this merged please? |
Since internally this library uses only Mention props, we can create our own Mention component that just follows the same API, so to make it work I did: const Mention = ({
id,
render,
display,
}) => {
if (render) {
return render({ children: display, label: display, value: id });
}
return <strong {...props}>{display}</strong>;
};
Mention.defaultProps = {
onAdd: () => null,
markup: "@[__display__](__id__)",
trigger: "@",
onRemove: () => null,
isLoading: false,
displayTransform: (id?: string | number, display?: string) => display || id,
renderSuggestion: null,
appendSpaceOnAdd: false,
}; And then I just use this Mention instead of the library one |
This PR includes the addition of the render method to the Mention component.
The method has display parameters and expects to return a react component to render the mention display value.
This would come in handy if there's a need to pass our own component instead of relying on the default functionality.
<Tooltip title="customTitleGoesHere"> <strong className="myClassName">{display}</strong> </Tooltip>