-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STCOR-952 break QueryStateUpdates out to their own class-based component. #1604
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I appreciate the detailed explanation of why we need this change in the PR description. Consider moving some of into a header comment on QueryStateUpdater to help folks understand why that component exists and that we know about its warts.
|
…ent. (#1604) Changes from [App reordering](https://folio-org.atlassian.net/browse/STCOR-936) - specifically a functional refactor of `MainNav` unearthed a handful of errors at the app level, causing behaviors with logic that updates query parameters/location. This PR takes the previous code from the class-based `MainNav` and places it in its own component: `QueryStateUpdater` - naming aside, this removes the potentially offending logic from `MainNav`, leaving it to the task of simply rendering the navigation/menus of the UI. The useEffect implementations of the functional `MainNav` were written to mirror the `componentDidMount` and `componentDidUpdate` lifecycle methods of the class-based version. When the `location` was added to the `cDM` dependency array in [This PR](#1600), this meant that the logic would no longer execute stricly on mount/dismount - but anytime that the `location` updated... this would cause page refreshes, as the logic would find a black `prevQueryState` every time and always update the location, causing a refresh. `componentDidUpdate` carried around its `prevProps`, unlike functional react, where a state might be needed to accomplish such a comparison - but this doesn't seem like an ideal solution for the functional version, so here we are. This is better because separately concerned logic is separated... worse because the separated logic still has all of its tentacles into the App layer and seems like a great example of a component that does too much - why wouldn't/couldn't updating queryState/location actually just live at the application level somehow? A question for future FOLIO... (cherry picked from commit 9cbaa1b)
Changes from App reordering - specifically a functional refactor of
MainNav
unearthed a handful of errors at the app level, causing behaviors with logic that updates query parameters/location. This PR takes the previous code from the class-basedMainNav
and places it in its own component:QueryStateUpdater
- naming aside, this removes the potentially offending logic fromMainNav
, leaving it to the task of simply rendering the navigation/menus of the UI.The useEffect implementations of the functional
MainNav
were written to mirror thecomponentDidMount
andcomponentDidUpdate
lifecycle methods of the class-based version. When thelocation
was added to thecDM
dependency array in This PR, this meant that the logic would no longer execute stricly on mount/dismount - but anytime that thelocation
updated... this would cause page refreshes, as the logic would find a blackprevQueryState
every time and always update the location, causing a refresh.componentDidUpdate
carried around itsprevProps
, unlike functional react, where a state might be needed to accomplish such a comparison - but this doesn't seem like an ideal solution for the functional version, so here we are.This is better because separately concerned logic is separated... worse because the separated logic still has all of its tentacles into the App layer and seems like a great example of a component that does too much - why wouldn't/couldn't updating queryState/location actually just live at the application level somehow? A question for future FOLIO...