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
How to remove the Zendesk Element? #28
Comments
If hiding the component is enough for your use case like it was for me, I'd recommend loading the component globally (e.g. using the <script> inside your page's head) and putting something like this in the component in which the Zendesk component is supposed to exist: useEffect(() => {
ZendeskAPI("webWidget", "show");
return () => {
ZendeskAPI("webWidget", "hide");
};
}, []); Hopefully this works for you, but it's far from ideal. Would probably be best if we could pass the Zendesk component something to be run when it unmounts. |
Thanks for your reply! 😄 For future reference; I've found that Zendesk doesn't like it if you repeatedly render Hence, if you're doing any kind of conditional showing and hiding of Zendesk, the best way to do it is to keep the FYI if you want Zendesk to be hidden by default when you're rendering it in the top-most file, this component supports
Side note: Zendesk show/hide APIs have a race condition which might also cause issues 🙃 |
Hi @Leulz is this the styling issue or i didn't get it. |
@lingaiah-danda The issue here is that the component isn't rendered only on the path you use it. Once it's rendered, it stays there on all other pages of the website. Hence my suggestion to hide the component once you leave the page you want it to be rendered on. |
When the Zendesk component is created, the Zendesk icon is permanently placed in the document due to
document.body.appendChild(script)
, even when the component where Zendesk is placed is unmounted.Is it possible to make it so that this works similar to a normal component, which unmounts when the parent is unmounted? (I imagine it's not easy since we're injecting a script here). If not, is there any way to remove the component on some sort of event?
The text was updated successfully, but these errors were encountered: