Skip to content
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

[DISP-72] Fix sorting in Ideas Map #1766

Conversation

lilkraftwerk
Copy link
Contributor

Bug here: https://citizenlab.atlassian.net/browse/DISP-72
To reproduce on master, the window must be larger than a certain breakpoint (not exactly sure which but full width on my laptop is big enough to reproduce). Changing the sorting here causes an infinite loop of requests:

Screenshot 2022-04-01 at 14 48 12

I believe the bug was due to passing arrays into the dependency array, which made React freak out when trying to reconcile the contents. This PR changes the dependency array for the useEffect function to use JSON.stringify on the arrays we were passing in, which makes them normal strings and therefore easy for React to reconcile. This fixes the bug on my local machine but please test before/after

I don't think there are many downsides using this fix, Dan Abramov of the React team recommends it here: facebook/react#14476 and it might be a little slower but likely not noticeable on this component

@lilkraftwerk lilkraftwerk requested a review from brentguf April 1, 2022 12:50
Copy link
Contributor

@kogre kogre left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks for the quick fix!

@brentguf
Copy link
Contributor

brentguf commented Apr 1, 2022

@lilkraftwerk could you check the linter issues?

@lilkraftwerk
Copy link
Contributor Author

@brentguf On it

@cl-dev-bot
Copy link
Collaborator

cl-dev-bot commented Apr 1, 2022

Warnings
⚠️ The branch name contains no Jira issue key (case-sensitive)
⚠️ The PR title contains no Jira issue key (case-sensitive)

Generated by 🚫 dangerJS against e0eeb9c

@lilkraftwerk lilkraftwerk merged commit 0c77fe1 into master Apr 1, 2022
@lilkraftwerk lilkraftwerk deleted the DISP-72-when-changing-the-idea-sorting-on-the-map-view-the-platform-gets-stuck branch April 1, 2022 13:17
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