fix: guard clipboard/eyedropper handlers against updates after unmount - #35
Conversation
|
Thanks for taking this on, and for being thorough about it. The catch is that this repo is on React 19, and since React 18 calling Two parts of this are genuinely worth keeping though:
Would you be up for trimming this down to just those two and dropping the |
|
Thanks for the detailed explanation — that's a fair point, and you're right that I conflated "state update after unmount" with "side effect after unmount." I hadn't accounted for React 18+ making unmounted I'll trim this down to just the two real fixes. |
…share-link button
Trimmed from the original guard-everywhere approach after review feedback:
since React 18+ makes setState on an unmounted component a silent no-op,
guarding copy-button.tsx, copy-menu.tsx, playground-actions.tsx,
color-picker.tsx, and html-in-canvas-banner.tsx didn't change any
observable behavior. Kept only the two guards that protect real,
perceivable side effects:
- preview-video.tsx: a cancelled flag prevents video.pause()/currentTime
reset from firing on the DOM node after the effect's cleanup has run.
- demo-controls.tsx (ShareLinkButton): a local mounted ref prevents
play("bloom") from firing an audible sound after the button is gone.
Dropped the shared useMountedRef() hook since it's no longer needed.
d19d3c8 to
b64519f
Compare
Fixes #39
What does this PR do?
Guards 6 clipboard/eyedropper handlers (+ preview-video.tsx) against calling setState / scheduling a new timer after the owning component has unmounted, using a new shared
useMountedRef()hook.Type of change
Checklist
npx tsc --noEmitpassesnpm run lintpassesnpm run buildpasses