Skip to content

Conversation

@PRAteek-singHWY
Copy link
Contributor

Summary

The Map Analysis page currently updates gapAnalysis state by mutating the existing object and forcing a re-render via a temporary undefined state. This pattern breaks React’s immutability guarantees and relies on a workaround that can lead to unnecessary renders and harder-to-reason-about behavior.

What Changed

This PR replaces the direct state mutation with an immutable update using the functional setState pattern. The new approach creates a fresh state object when weak links are loaded, allowing React to re-render correctly without forcing intermediate state resets.

Why This Matters

  • Removes a known React anti-pattern (explicitly called out in the code comment)
  • Avoids forced re-renders and potential race conditions
  • Improves maintainability and correctness without changing user-visible behavior
  • Keeps the change tightly scoped to state management only

Scope

  • UI-only change
  • No backend or API changes
  • No behavior or layout changes beyond the internal state update

Copy link
Collaborator

@northdpole northdpole left a comment

Choose a reason for hiding this comment

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

great work

@northdpole northdpole merged commit 0e09bb5 into OWASP:main Jan 24, 2026
2 checks passed
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