Skip to content
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

Hint doesn't re-render if data-rh is changed and hint is visible #15

Closed
ayal opened this issue Jan 25, 2018 · 3 comments
Closed

Hint doesn't re-render if data-rh is changed and hint is visible #15

ayal opened this issue Jan 25, 2018 · 3 comments
Labels

Comments

@ayal
Copy link

ayal commented Jan 25, 2018

Say that I have a div with data-rh={this.state.hintText}, on hover it shows.
Let's say I have an onClick on that element and when clicked I change state.hintText to something else - the element re-renders but the hint stays the same.

Only after mouseout/in does it renders correctly.

Could not find a workaround with available methods.

@slmgc
Copy link
Owner

slmgc commented Jan 25, 2018

You can do something like this: get the instance of ReactHint

<ReactHint events ref={(ref) => this.instance = ref} />

And then call this.instance.forceUpdate() when you need to update the contents of the tooltip. Let me know if it solves your issue.

@slmgc slmgc added the question label Jan 25, 2018
@slmgc
Copy link
Owner

slmgc commented Jan 29, 2018

@ayal closing the issue, feel free to reopen in case the solution doesn't work for you.

@slmgc slmgc closed this as completed Jan 29, 2018
@ayal
Copy link
Author

ayal commented Feb 5, 2018

Hey, thanks for your quick reply and sorry for my late reply. I tried this before and it didn't work - only now noticed I had two instances of <ReactHint .../> in my code since in the readme example you put two instances and it's a bit confusing. Anyways it works with one instance using the "forceupdate" solution. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants