Skip to content

Conversation

@mocca102
Copy link
Contributor

@mocca102 mocca102 commented Dec 2, 2024

This is the actual change https://github.com/Constructor-io/constructorio-ui-autocomplete/pull/185/files#diff-e01e5eee29c745e3c8683f0945e6922b47b1fc39888e1c3ce8d4b6c7a7964184R21

The rest is much-needed refactoring since the code was highly not readable

Before
Autocomplete _ Component - Docs ⋅ Storybook (1)

After
Autocomplete _ Component - Docs ⋅ Storybook (1) (1)

@mocca102 mocca102 requested a review from a team as a code owner December 2, 2024 11:11
@@ -0,0 +1,42 @@
/* eslint-disable max-params */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this being disabled in a lot of places. If it doesn't match our coding style here, should we disable it from our eslint config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not even needed here anymore I'm removing it.

I'd rather we leave it since it gives an indicator even we bypass it that the hook might need refacotoring or split.

@@ -0,0 +1,76 @@
/* eslint-disable max-params */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to rename this file to index.ts to avoid having imports with ../useSections/useSections, specially if this hook is exposed to users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout!

// Access the Pods Data from the Recommendations response to update Active Sections configuration
useEffect(() => {
if (!recommendations.podsData) {
setPodsData(recommendations.podsData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only ever set if podsData is falsy? Or does podsData get a value set to it elswhere?

Copy link
Contributor Author

@mocca102 mocca102 Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only ever set if podsData is falsy

Here yes. "setPodsData" only purpose is to give useRemoveSections access to recommendations.podsData

If we didn't have useRemoveSections all code related to saving podsData in state would be removed since already we are keeping track of podsData in a different useState is in useFetchRecommendationPod

@mocca102 mocca102 requested a review from ZSnake December 24, 2024 17:21
@mocca102 mocca102 merged commit 800aa47 into main Dec 26, 2024
10 checks passed
@mocca102 mocca102 deleted the noci-fix-dropdown branch December 26, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants