React-tooltip: Ternary renders prevent tooltip from opening.

Created on 14 Oct 2019  Â·  5Comments  Â·  Source: wwayne/react-tooltip

{auth.user && auth.user[0].privilege_level < 5 ? ( <Menu.Item name="Pending Tickets" data-tip="Pending Data Ops" as={Link} to="/pending-data-ops" > <Icon name="address card" /> </Menu.Item> ) : null}

The above code renders the menu item based on the user level. The Ternary wrapper stops the tooltip from rendering.
This can be avoided by adding the data-tip prop to a wrapper above the ternary, maybe not a bad issue, might want to put in docs? I dunno take this info and do with it what you need lol.

This works:
<div data-tip="Pending Data Ops"> {auth.user && auth.user[0].privilege_level < 5 ? ( <Menu.Item name="Pending Tickets" as={Link} to="/pending-data-ops"> <Icon name="address card" /> </Menu.Item> ) : null} </div>

Most helpful comment

Hello, you have to rebuild the tooltip component with ReactTooltip.rebuild() (i did this after setState)

I did and worked for me, i can't do your solution with my code because of the structure is a quit different. hope it will help you

All 5 comments

Hello, you have to rebuild the tooltip component with ReactTooltip.rebuild() (i did this after setState)

I did and worked for me, i can't do your solution with my code because of the structure is a quit different. hope it will help you

Awesome, I will try that out. Thank you!

It worked for me too. Adding it to the docs would have saved me a lot of time.

Pull request welcome! Add it where you think it's helpful and I'll get it
in.

On Fri, Oct 25, 2019 at 6:03 AM Dimitris Raptis notifications@github.com
wrote:

It worked for me too. Adding it to the docs would have saved me a lot of
time.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/wwayne/react-tooltip/issues/517?email_source=notifications&email_token=AEX6THITLCB4AC7W4M4UWELQQK75JA5CNFSM4JAPF4R2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECH3ZCI#issuecomment-546290825,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AEX6THIU43G23GT7UJT3QALQQK75JANCNFSM4JAPF4RQ
.

Sure. Once I find some time, I'll open a PR

Was this page helpful?
0 / 5 - 0 ratings