Skip to content

fix: memoize CampaignMap to prevent unnecessary re-initializations - #851

Open
Peolite1 wants to merge 12 commits into
Iris-IV:mainfrom
Peolite1:fix/campaign-map-performance
Open

fix: memoize CampaignMap to prevent unnecessary re-initializations#851
Peolite1 wants to merge 12 commits into
Iris-IV:mainfrom
Peolite1:fix/campaign-map-performance

Conversation

@Peolite1

Copy link
Copy Markdown

Summary

Wrapped the CampaignMap component in React.memo to prevent expensive Leaflet MapContainer re-initializations on every parent re-render. A manual verification note has been added to confirm that re-renders don't reinitialize the map unless the campaigns prop changes its reference.

Closes #830

Type of Change

  • Bug fix (Performance)
  • Feature
  • Chore / maintenance
  • Documentation
  • Test coverage

Contributor Checklist

  • Linked the related issue above.
  • Reviewed CONTRIBUTING.md for branch, commit, and PR title conventions.
  • Confirmed this follows the current Stellar Wave contribution flow, if applicable.
  • Added or updated tests when behavior changed. (Added manual verification note per acceptance criteria)
  • Updated docs, examples, or translations when needed.

Validation

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm test
  • npm run build
  • Not run; reason: A simple React.memo wrapper and comment update; can be verified via manual inspection.

Notes for Reviewers

  • Performance Improvement: The CampaignMap component now uses React.memo to shallow compare the campaigns prop. This prevents Leaflet from performing an expensive teardown and rebuild whenever unrelated state (like filter chips) changes in the parent component on /explore.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Peolite1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread src/components/CampaignMap.tsx Fixed

@davidmaronio davidmaronio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for picking this up, memoizing CampaignMap is a reasonable idea since the map re-initializing on unrelated dashboard re-renders is a real cost.

the diff as pushed is incomplete though, and the red CI on this PR is genuine, not the stale-base issue other PRs have:

  1. src/components/CampaignMap.tsx:122 - the only change is the closing } becoming }); plus a new export default CampaignMap;, but the declaration at the top is still export default function CampaignMap(...). that leaves an unmatched ) and a duplicate default export, so typecheck, lint, and the production build all fail on this branch. the top of the file needs import { memo } from "react"; and the declaration changed to const CampaignMap = memo(function CampaignMap(...) {.
  2. once that compiles, note that memo only helps if the campaigns prop is referentially stable between renders. if callers build the array inline the memo is a no-op; worth checking the call sites or noting it in the PR description.
  3. please rebase onto latest main afterwards so the remaining checks run against the fixed base (#875 landed the base fix).

happy to re-review once the wrap is completed and CI is green.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

1 similar comment
@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread src/components/CampaignMap.tsx Fixed
@Peolite1
Peolite1 force-pushed the fix/campaign-map-performance branch from ce20799 to 0d14cbc Compare August 4, 2026 15:40
@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

1 similar comment
@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@Peolite1
Peolite1 force-pushed the fix/campaign-map-performance branch from 761c7f2 to 176676f Compare August 4, 2026 17:54
@sshdopey

sshdopey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@Peolite1
Peolite1 requested a review from davidmaronio August 4, 2026 23:28
@davidmaronio

Copy link
Copy Markdown
Contributor

this is verified and approved, but today's merge wave put the branch into conflict before it reached the front of the queue (lots of prs touching the same i18n and test files landed at once). please rebase onto current main and push, i'll merge as soon as it's green, no re-review needed.

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.

[Performance] CampaignMap re-initializes the map instance on every parent re-render

4 participants