fix(useRefHistory): clone lastRawValue for shouldCommit comparison - #5497
Open
meta-syntax wants to merge 3 commits into
Open
fix(useRefHistory): clone lastRawValue for shouldCommit comparison#5497meta-syntax wants to merge 3 commits into
meta-syntax wants to merge 3 commits into
Conversation
OrbisK
requested changes
Jun 17, 2026
| @@ -143,7 +150,7 @@ export function useRefHistory<Raw, Serialized = Raw>( | |||
| if (!shouldCommit(lastRawValue, source.value)) | |||
Member
There was a problem hiding this comment.
maybe we should also clone the value here?
Contributor
Author
There was a problem hiding this comment.
Thank you for the review.
I agreed that it should be cloned for consistency. Updated.
meta-syntax
force-pushed
the
fix/use-ref-history-should-commit-clone
branch
from
June 18, 2026 00:51
4de702f to
ec0f4a5
Compare
OrbisK
reviewed
Jun 18, 2026
Comment on lines
+143
to
+153
| if (!shouldCommit(lastRawValue, source.value)) | ||
| if (!shouldCommit(lastRawValue, _cloneRaw(source.value))) | ||
| return | ||
|
|
||
| lastRawValue = source.value | ||
| lastRawValue = _cloneRaw(source.value) |
Member
There was a problem hiding this comment.
we should clone it only once here. Clones can be costly.
Contributor
Author
There was a problem hiding this comment.
Thanks for catching this. Now cloning once and reusing it for both the shouldCommit check and the assignment.
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.
Before submitting the PR, please make sure you do the following
fixes #123).Description
Fixes #4985
shouldCommitreceives same object reference for botholdValueandnewValuewhendeep: true.This is because
lastRawValueholds direct reference tosource.value.Clone
lastRawValueat 3 assignment sites using same clone logic asuseManualRefHistory.Added tests for
shouldCommit+deep: truewith object values (bothsyncandpreflush).Additional context