yardz commented on a change in pull request #13220:
URL: https://github.com/apache/superset/pull/13220#discussion_r578874263
##########
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:
There are extremely complex class components in the application that use
ComponentDidMount. Refactoring this and removing this behavior in one step will
be extremely difficult and at a very high risk.
So it is absolutely not true that hooks are "a new style of business logic
organization that focuses on data flow rather than component lifecycles". The
main motivations are **"It's hard to reuse stateful logic between
components"**, **"Complex components become hard to understand"** and
**"Classes confuse both people and machines"** and they say the hooks are for:
**"Hooks let you use more of React's features without classes"**.
Clearly their intention is to provide the same lifecicle/features of classes
for functions, facilitate the reuse of code and reduce the size/complexity of
the components.
----------------------------------------------------------------
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]