Repository navigation
fix: stabilize selector-derived room snapshots - #13
Closed
under-undefined wants to merge 1 commit into
Closed
under-undefined wants to merge 1 commit into
under-undefined wants to merge 1 commit into
Conversation
Member
|
Hi @under-undefined - thank you for reporting and for sharing the reproduction scenarios - can you please check if version 0.1.19 fixes this for you? Took a slight different approach to your PR there |
Author
|
@endel 0.1.19 Fixed 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Colyseus
Schema,MapSchema, andArraySchemanodes have stablerefIdvalues, allowingcreateSnapshot()to reuse previous results throughresultsByRefId.Selector-created arrays and objects do not have a Colyseus
refId. As a result, everygetSnapshot()call produced a new root reference, even when the room state had not changed.This violates the referential stability requirement of
useSyncExternalStore()and causes React to repeatedly render until it throws:Solution
Add hook-local structural sharing for selector-derived root containers that do not have a Colyseus
refId.The new behavior:
resultsByRefIdbehavior unchanged for normal Colyseus Schema roots.MapSchema#get()andMapSchema#values().Tests
Added regression coverage for: