yardz commented on a change in pull request #13220:
URL: https://github.com/apache/superset/pull/13220#discussion_r578864774



##########
File path: superset-frontend/src/explore/components/ExploreViewContainer.jsx
##########
@@ -146,11 +147,11 @@ const getWindowSize = () => ({
 function useWindowSize({ delayMs = 250 } = {}) {
   const [size, setSize] = useState(getWindowSize());
 
-  useEffect(() => {
+  useComponentDidMount(() => {
     const onWindowResize = debounce(() => setSize(getWindowSize()), delayMs);
     window.addEventListener('resize', onWindowResize);
     return () => window.removeEventListener('resize', onWindowResize);
-  }, []);
+  });

Review comment:
       @ktmud and @suddjian about the warning.
   
   This ``[]`` causes a warning! And the only way to eliminate it is by adding  
`` // eslint-disable-next-line react-hooks/exhaustive-deps `` unfortunately it 
cannot be avoided.
   Even in cases where it is desired to be executed only once, it is necessary 
to put "eslint-disable"... Of course, lint rules exist for a reason, but again, 
in this case the rule is not smart enough to understand that the desired 
behavior is exactly that.
   
   So there are two choices, 1- put "eslint disable" in all the places where we 
want to execute the effect only once (currently we have something close to 7 
files like this) or 2- centralize "eslint-disable" and reduce this as much as 
possible.
   
   It seems to me that not adopting such a hook reinforces the use of 
"eslint-disable"... Which for me is a much worse practice.
   




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

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