-
Notifications
You must be signed in to change notification settings - Fork 125
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
Conflict with react-query devtools #1425
Comments
hey @tyteen4a03 Can you share more info about what happens? Do you see any errors in the network panel or the console? Is that this dev tools? https://tanstack.com/query/latest/docs/framework/react/devtools |
No warnings or errors, clicking on the toggle just instantly closes the toolbar without actually toggling the FF. Yes, that's the package. |
Wild... do other interactions in the toolbar work? |
I just checked again, none of the click interactions work. |
Hey folks! I was having the same issue and I realized that this is because Tanstack Query Devtools is adding a In order to prevent this, I created a React component that adds a new event listener for the import { useEffect } from 'react';
export const PosthogToolbarGuardAgainstTanstackDevtools = () => {
useEffect(() => {
let observer: MutationObserver | null = null;
// Function to check and attach the event listener if the element is present
const checkAndAttachListener = () => {
const posthogToolbar = document.getElementById('__POSTHOG_TOOLBAR__');
if (posthogToolbar) {
const stopEvent = (e: MouseEvent) => {
e.stopImmediatePropagation();
};
posthogToolbar.addEventListener('mousedown', stopEvent);
// Cleanup function to remove the event listener and disconnect the observer
return () => {
posthogToolbar.removeEventListener('mousedown', stopEvent);
if (observer) observer.disconnect();
};
}
};
// Observer callback triggers when any changes in child elements of the body occur
observer = new MutationObserver(checkAndAttachListener);
observer.observe(document.body, { childList: true, subtree: true });
// Return cleanup function to disconnect observer on unmount
return () => {
if (observer) observer.disconnect();
};
}, []);
return null;
}; You can use this component inside the <PostHogProvider apiKey={import.meta.env.VITE_POSTHOG_API_KEY} options={posthogOptions}>
<PosthogToolbarGuardAgainstTanstackDevtools />
{children}
</PostHogProvider> Let me know if this works for you! |
@rmanganiello thank you! Do you think this is an issue on TanStack's end? |
Not sure yet, I need to keep checking the Tanstack Devtools Library to understand where the issue is generated. |
When I have both PostHog Toolbar and React Query DevTools in my application, toggling Feature Flags stop working.
The text was updated successfully, but these errors were encountered: