korbit-ai[bot] commented on code in PR #33553:
URL: https://github.com/apache/superset/pull/33553#discussion_r2101594522


##########
superset-frontend/src/pages/AllEntities/index.tsx:
##########
@@ -100,6 +103,10 @@ function AllEntities() {
     query: [],
   });
 
+  const canEditTag = useSelector((state: RootState) =>
+    findPermission('can_write', 'Tag', state.user?.roles),
+  );

Review Comment:
   ### Unmemoized Permission Selector <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   Permission check is performed on every render without memoization, 
potentially causing unnecessary re-renders of child components.
   
   
   ###### Why this matters
   Without memoization, the selector will run on every render even if the 
user's roles haven't changed, which can impact performance especially in a 
complex component tree.
   
   ###### Suggested change ∙ *Feature Preview*
   Use useMemo or reselect to memoize the permission check:
   ```typescript
   const canEditTag = useSelector(
     useMemo(
       () => (state: RootState) => findPermission('can_write', 'Tag', 
state.user?.roles),
       []
     )
   );
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/97daaf7b-63a9-46a0-89c9-2063816be25e/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/97daaf7b-63a9-46a0-89c9-2063816be25e?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/97daaf7b-63a9-46a0-89c9-2063816be25e?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/97daaf7b-63a9-46a0-89c9-2063816be25e?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/97daaf7b-63a9-46a0-89c9-2063816be25e)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:e4d3388e-c0f7-4ddd-bfcb-c19a02fc7eb0 -->
   
   
   [](e4d3388e-c0f7-4ddd-bfcb-c19a02fc7eb0)



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