Skip to content

Comments

Add RAF cleanup on unmount to prevent state updates after unmount#1333

Merged
langonginc merged 3 commits intoreduce-reduxfrom
copilot/sub-pr-1332
Feb 12, 2026
Merged

Add RAF cleanup on unmount to prevent state updates after unmount#1333
langonginc merged 3 commits intoreduce-reduxfrom
copilot/sub-pr-1332

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

  • Review feedback from PR #1331 Enhance scripting performance when dragging canvas #1332 comment #2797797038
  • Add cleanup useEffect to cancel RAF on component unmount
  • Move cleanup useEffect after all event handlers (comment #3889831649)
  • Verify lint passes
  • Verify tests pass
  • Address memory leak risk when component unmounts with pending RAF

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: langonginc <59787082+langonginc@users.noreply.github.com>
Copilot AI changed the title [WIP] Update on scripting performance enhancements for canvas dragging Add RAF cleanup on unmount to prevent state updates after unmount Feb 12, 2026
Copilot AI requested a review from langonginc February 12, 2026 09:42
@langonginc
Copy link
Member

@copilot Move it after all event handlers

Co-authored-by: langonginc <59787082+langonginc@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 12, 2026

@copilot Move it after all event handlers

Moved cleanup useEffect to after all event handlers for better code organization. (commit 0927479)

@langonginc langonginc marked this pull request as ready for review February 12, 2026 09:50
Copilot AI review requested due to automatic review settings February 12, 2026 09:50
@langonginc langonginc merged commit c976180 into reduce-redux Feb 12, 2026
5 checks passed
@langonginc langonginc deleted the copilot/sub-pr-1332 branch February 12, 2026 09:52
Copy link
Contributor

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

Adds a component-unmount cleanup to prevent a pending requestAnimationFrame callback from firing after SvgWrapper has unmounted, avoiding post-unmount setState calls and related leak/warning risk.

Changes:

  • Add a useEffect cleanup that cancels any in-flight RAF on unmount.
  • Reset rafRef.current to null during cleanup to keep state consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants