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(react): ensure edges are materialized when React runs effects #166

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

bowheart
Copy link
Collaborator

@bowheart bowheart commented Feb 7, 2025

Description

The changes in #154 ensured that edges recreate themselves if other components destroy them when React is running effects, but I missed two things:

  • The _prevEdge references are not cleared when we run a cleanup cycle.
  • Edges that are destroyed by other component effects and recreated don't have isMaterialized: true.

I actually didn't miss these, but I missed the fact that together, they mean that components added later will continue adding to the existing singly-linked list chain and when later cleanup cycles walk up that chain, they'll see non-materialized nodes.

The fix is easy: Either break the chain when a cleanup cycle runs (by clearing _prevEdge references) or always create pre-materialized nodes in useEffects. The former is risker - it may still be vulnerable to who-knows-what React rendering sequences, and the weak ref chain cleans itself up anyway - so do the latter.

Issues

Resolves #165

@bowheart bowheart merged commit 9530358 into v1.x Feb 7, 2025
2 checks passed
@bowheart bowheart deleted the josh/165 branch February 7, 2025 00:17
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.

1 participant