anuragp010 opened a new pull request, #10677:
URL: https://github.com/apache/ozone/pull/10677

   
   
   ## What changes were proposed in this pull request?
   2 Independent issues are present in the `omDBInsights` page when we change 
the value for limit.
   
   **1. 2 API calls are made per tab endpoint when we change the limit:**
   _Root Cause:_
   - Each OM DB Insights tab uses the useApiData hook to fetch data. This hook 
also refetches the data when there is change in the URL.
   - Each tab also defines a separate useEffect hook that refetches the data 
through useApiData when limit.value changes.
   - By behaviour, changing the limit results in changing the URL. As a result, 
we have 2 listeners - one is useApiData listening to changes in URL and the 
other in the same Table listening to limit.value changes. This results in 2 
calls to useApiData.
   
   _Fix_:
   The redundant useEffect in the OMDBInsights tab pages, which listens to 
limit.value changes was removed.
   
   **2. Changing the limit results in fetching data for all 5 tab endpoints 
even though only one tab is active:**
   _Root Cause:_
   - Limit's state lives in the parent and is shared across all tabs.
   - Ant Design Tabs mounts the tab content on the first visit to a tab. These 
tabs remain mounted even when inactive (default behaviour of Ant design tabs). 
   - Changing the limit, results in changing the state for all tabs which are 
mounted, resulting in refetching data for all tabs.
   
   _Fix:_
   Unmount inactive tabs from the ant design tabs using the 
destroyInactiveTabPane prop.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-14544
   
   ## How was this patch tested?
   Network Tab in browser.
   
   **Before the changes:**
   <img width="231" height="307" alt="image" 
src="https://github.com/user-attachments/assets/41ca548d-76a0-4fa3-baf9-35ad24ed104d";
 />
   - All tabs on the OMDBInsights page are opened once.
   - Limit is changed resulting in 2 API calls per tab, for all tabs.
   
   **After the changes:**
   <img width="382" height="143" alt="image" 
src="https://github.com/user-attachments/assets/be3aa653-513d-4f4d-91be-e2237d695d41";
 />
   - All tabs on the OMDBInsights page are opened once.
   - Limit is changed resulting in a single API call for the active tab.


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