You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "bronz3beard (via GitHub)" <gi...@apache.org> on 2024/09/12 13:07:08 UTC
Re: [I] fetchGuestToken callback running in an Infinite Loop. [superset]
bronz3beard commented on issue #24765:
URL: https://github.com/apache/superset/issues/24765#issuecomment-2346236431
not great practice in react but this could be a solution, less involved than the above suggestion.
```
import { useEffect, useRef } from 'react';
const useEffectOnce = (effect: () => void) => {
const hasRun = useRef(false);
useEffect(() => {
if (!hasRun.current) {
hasRun.current = true;
return effect();
}
}, [effect]);
};
export default useEffectOnce;
```
```
useEffectOnce(() => {
embedDashboard({
id: "superset-dashboard-id", // given by the Superset embedding UI
supersetDomain: "https://superset-bas-dev.bridge.propelmarine.com",
mountPoint: document.getElementById("superset-container") as HTMLElement, // any html element that can contain an iframe
fetchGuestToken: async () => {
console.log("fetchGuestToken");
return guestToken;
},
dashboardUiConfig: {
// dashboard UI config: hideTitle, hideTab, hideChartControls, filters.visible, filters.expanded (optional)
hideTitle: true,
filters: {
expanded: false,
},
},
});
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org