Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Reattaching an element does not re-run the effects #59

Merged
merged 3 commits into from
Feb 22, 2025

Conversation

cristinecula
Copy link
Contributor

@cristinecula cristinecula commented Feb 21, 2025

Fixed by resetting the internal state of effects when the element is disconnected. This ensures that when it is reconnected, it will run all effects.

Also fixed an issue where the teardown function is ran twice when re-attaching (once when you detach and once when you attach).

Re matthewp/haunted#492
Re #58

@cristinecula cristinecula added the bug Something isn't working label Feb 21, 2025
@cristinecula cristinecula self-assigned this Feb 21, 2025
Copy link

changeset-bot bot commented Feb 21, 2025

🦋 Changeset detected

Latest commit: 1ae8c96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@pionjs/pion Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cristinecula cristinecula changed the title added failing test for effect reattach bug Fix: Reattaching an element does not re-run the effects Feb 21, 2025
Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for pionjs ready!

Name Link
🔨 Latest commit 1ae8c96
🔍 Latest deploy log https://app.netlify.com/sites/pionjs/deploys/67b91265d71ac7000864851d
😎 Deploy Preview https://deploy-preview-59--pionjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cristinecula cristinecula force-pushed the feature/use-effect-reattach-bug branch from a7bd828 to 1f8b39d Compare February 21, 2025 23:55
@cristinecula cristinecula marked this pull request as ready for review February 21, 2025 23:55
Also handled situation where teardown was ran multiple times when
reattaching.

Fixes #58
@cristinecula cristinecula force-pushed the feature/use-effect-reattach-bug branch from 1f8b39d to 1ae8c96 Compare February 21, 2025 23:55
Copy link
Contributor

@megheaiulian megheaiulian left a comment

Choose a reason for hiding this comment

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

Amazing work @cristinecula. Thank you for fixing this nasty bug.

@cristinecula cristinecula merged commit a948e76 into main Feb 22, 2025
9 checks passed
@cristinecula cristinecula deleted the feature/use-effect-reattach-bug branch February 22, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants