Skip to content

⚡ Memoize project filtering in ProjectsSection#33

Draft
WebCraftPhil wants to merge 1 commit into
mainfrom
optimize-projects-section-5149260371857232735
Draft

⚡ Memoize project filtering in ProjectsSection#33
WebCraftPhil wants to merge 1 commit into
mainfrom
optimize-projects-section-5149260371857232735

Conversation

@WebCraftPhil

@WebCraftPhil WebCraftPhil commented May 21, 2026

Copy link
Copy Markdown
Owner

The ProjectsSection component was recalculating the filteredProjects array on every render, even if the filter state hadn't changed. This PR introduces useMemo to memoize the filtered results based on the filter dependency. Additionally, the static categories array has been moved outside the component function to prevent it from being re-allocated during every render cycle. These changes reduce unnecessary CPU cycles and memory allocations, improving the component's performance.


PR created automatically by Jules for task 5149260371857232735 started by @WebCraftPhil

Summary by Sourcery

Optimize project listing rendering in ProjectsSection by memoizing filtered results and avoiding per-render category allocation.

Enhancements:

  • Memoize filtered projects based on the selected filter to avoid unnecessary recomputation on re-renders.
  • Hoist the static project categories definition outside the ProjectsSection component to prevent repeated allocations.

…mponent

- Wrapped `filteredProjects` in `useMemo` to prevent recalculation on every render.
- Moved `categories` array definition outside the `ProjectsSection` component to avoid re-allocation on every render.
- Added `useMemo` to React imports.

Co-authored-by: WebCraftPhil <118385120+WebCraftPhil@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
philgreene-net Ready Ready Preview, Comment May 21, 2026 2:16am

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69907a8e-12ed-45f4-ac5f-f45a258f4d23

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optimize-projects-section-5149260371857232735

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented May 21, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Memoizes project filtering in ProjectsSection and hoists the categories definition to avoid per-render allocations, improving performance and keeping behavior unchanged.

Sequence diagram for memoized filtering in ProjectsSection

sequenceDiagram
  participant React
  participant ProjectsSection
  participant useMemo
  participant projects

  React->>ProjectsSection: render(filter)
  ProjectsSection->>useMemo: computeFilteredProjects(filter)
  alt [filter changed]
    useMemo->>projects: filter(category === filter)
    useMemo-->>ProjectsSection: new filteredProjects
  else [filter unchanged]
    useMemo-->>ProjectsSection: cached filteredProjects
  end
Loading

File-Level Changes

Change Details Files
Memoize filtered projects based on the filter state to avoid recomputing on every render.
  • Wraps filteredProjects computation in useMemo with filter as dependency.
  • Preserves existing filtering logic for 'all' and specific categories using projects.filter.
  • Ensures filteredProjects is only recalculated when filter changes rather than on every render.
client/src/components/ProjectsSection.tsx
Hoist static categories definition outside the ProjectsSection component to avoid re-allocating it on each render.
  • Moves the categories array from inside the ProjectsSection component to a top-level const next to projects.
  • Keeps category ids and labels unchanged to preserve existing UI and behavior.
client/src/components/ProjectsSection.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

1 participant