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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]