8000 App Groups - Test memo all the things app groups by savathoon · Pull Request #311 · discord/access · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

App Groups - Test memo all the things app groups #311

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 8000

Merged
merged 2 commits into from
Jul 2, 2025
Merged

Conversation

savathoon
Copy link
Contributor

No description provided.

@savathoon savathoon requested a review from Copilot July 1, 2025 20:31
Copilot

This comment was marked as outdated.

@discord discord deleted a comment from Copilot AI Jul 1, 2025
@savathoon savathoon marked this pull request as ready for review July 1, 2025 20:48
@tonydelanuez
Copy link
Contributor

Unrelated to this PR, can we move the Apps*.tsx components into a src/components/Apps/ folder?

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR greatly improves rendering performance for app-related components by introducing memoization and stabilizing callbacks.

  • Wrapped key components (AppsHeader, AppsAdminActionGroup, AppsAccordionListGroup) and subcomponents in React.memo
  • Used useMemo, useCallback, and refs to prevent unnecessary recomputations and re-renders
  • Added guards in state setters to update only on actual data changes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/pages/apps/components/AppsHeader.tsx Wrapped header in React.memo; memoized hasActions and tagChips
src/pages/apps/components/AppsAdminActionGroup.tsx Wrapped admin actions in React.memo; memoized data transforms and callbacks with refs
src/pages/apps/components/AppsAccordionListGroup.tsx Refactored accordion into memoized subcomponents; optimized prop comparisons
src/pages/apps/Read.tsx Memoized initial groups and stabilized toggle/search handlers with useCallback
Comments suppressed due to low confidence (1)

src/pages/apps/components/AppsAdminActionGroup.tsx:17

  • The default for isExpanded was changed from true to false, altering the initial expand behavior. If this wasn’t intentional, restore the previous default or explicitly pass the prop from the parent.
  ({currentUser, app, onSearchSubmit, onToggleExpand, isExpanded = false}) => {

}}
/>
));
}, [app.active_app_tags, navigate]);
Copy link
Preview
Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

The navigate dependency isn't used inside the useMemo for tagChips. Consider removing it to avoid needless invalidations.

Suggested change
}, [app.active_app_tags, navigate]);
}, [app.active_app_tags]);

Copilot uses AI. Check for mistakes.

</Stack>
);
},
(prevProps, nextProps) => {
Copy link
Preview
Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The custom comparison in React.memo only checks member_list length and IDs; if other fields change, the memo might skip necessary updates. Consider deeper comparisons or adjusting props to avoid stale renders.

Copilot uses AI. Check for mistakes.

Comment on lines +28 to +34
const initialNonOwnerAppGroups = React.useMemo(() => {
return app?.active_non_owner_app_groups || [];
}, [app?.active_non_owner_app_groups]);

React.useEffect(() => {
setNonOwnerAppGroups(app?.active_non_owner_app_groups || []);
}, [data]);
setNonOwnerAppGroups(initialNonOwnerAppGroups);
}, [initialNonOwnerAppGroups]);
Copy link
Preview
Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The useMemo for initialNonOwnerAppGroups may be unnecessary since it's only used once in the effect. You could depend directly on app.active_non_owner_app_groups in the effect to simplify.

Copilot uses AI. Check for mistakes.

@savathoon
Copy link
Contributor Author

Unrelated to this PR, can we move the Apps*.tsx components into a src/components/Apps/ folder?

The current structure was a compromise, I don't really want to revisit changes until we have a general rule for the whole frontend app

@savathoon savathoon merged commit e02fe03 into main Jul 2, 2025
6 checks passed
@savathoon savathoon deleted the use-memo branch July 2, 2025 18:47
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.

2 participants
0