-
Notifications
You must be signed in to change notification settings - Fork 28
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
Multiple instances of react-hint: how to use ReactHintFactory properly? #10
Comments
Hi, let me try to help you out! <App>
<ReactHint />
<UserActions />
<UserActions />
<UserActions />
...
</App> In case you absolutely need to define it in multiple places (strongly discouraged), you can re-define the attribute name for each instance, like this: ...
constructor(...args) {
super(...args)
this._hintId = 'data-rh-' + +new Date // some unique id
}
...
render() {
return (
<div className="UserActions">
<ReactHint attribute={this._hintId} events delay={120} position={this.props.tooltipPosition} ref={(ref) => this.rhInstance = ref} />
...
} |
Ah - thInking I needed to add the component within multiple components is where I was going wrong - thanks so much for your help! |
@howells is there a way to make it more clear in the docs? |
@slmgc I think it's me just being a noob and now it's clear. I guess make it clear that the tooltip should only be instantiated once across the whole app and use the data attributes to configure |
I have a similar issue, but my use case is that I'm exporting a react component that uses react-hint. This component can be instantiated multiple times, meaning that it will create multiple instances of react hint... which is resulting in weird UX. |
@gion |
I'm having great trouble using react-hint across multiple, individual components in my app.
If react-hint is included multiple times, I end up with multiple tooltips appears on every hover. I think it's because I'm setting up each instance using:
const ReactHint = ReactHintFactory(React)
and so ReactHint is using the same root but I don't understand how I can set up a new instance specific to the component in which it's embedded, if that makes sense?!
https://gist.github.com/howells/f7de166446d75537a0a50ab9de205ba4
this component, UserActions, can appear many many times within an component, so I need the hints to be scoped to just that instance of the component.
Any help much appreciated!
The text was updated successfully, but these errors were encountered: