bito-code-review[bot] commented on PR #39893:
URL: https://github.com/apache/superset/pull/39893#issuecomment-4381318849

   <!-- Bito Reply -->
   Yes, the suggestion is valid — StrictMode's double-invocation in development 
causes the store.subscribe in EmbededLazyDashboardPage's render to create 
duplicate subscriptions without cleanup, leading to memory leaks and repeated 
observeDataMask emissions. To resolve, move the subscription logic into 
useEffect with cleanup: import useEffect, then wrap the subscribe call in 
useEffect(() => { const unsubscribe = store.subscribe(...); return unsubscribe; 
}, [uiConfig.emitDataMasks]). There are no other comments on this PR.
   
   **superset-frontend/src/embedded/index.tsx**
   ```
   import { useEffect } from 'react';
   
   // Inside EmbededLazyDashboardPage
   function EmbededLazyDashboardPage() {
     // ... existing code ...
     useEffect(() => {
       if (uiConfig.emitDataMasks) {
         let previousDataMask = store.getState().dataMask;
         const unsubscribe = store.subscribe(() => {
           const currentDataMask = store.getState().dataMask;
           if (currentDataMask !== previousDataMask) {
             previousDataMask = currentDataMask;
             Switchboard.emit('observeDataMask', ...);
           }
         });
         return unsubscribe;
       }
     }, [uiConfig.emitDataMasks]);
     // Remove the inline subscribe logic
   }
   ```


-- 
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]

Reply via email to