Skip to content

fix(useHistoryTravel): preserve batched history updates - #2978

Merged
crazylxr merged 2 commits into
alibaba:masterfrom
Aminark:fix/history-travel-batched-updates
Oct 26, 2026
Merged

crazylxr merged 2 commits into
alibaba:masterfrom
Aminark:fix/history-travel-batched-updates

Conversation

@Aminark

@Aminark Aminark commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix

Background and solution

Calling setValue('first') and setValue('second') in the same event loses the first value from the history. Both calls read the state from the same render. Batched back/forward calls have the same problem.

Use functional state updates so each operation starts from the previous operation's result. Tests cover consecutive updates, navigation, reset followed by an update, redo history, and the history limit.

Validation: all 418 hook tests and 8 use-url-state tests pass. The package build and formatting checks pass.

Changelog

Language Changelog
English Fix lost history when useHistoryTravel updates are batched.
中文 修复 useHistoryTravel 批量更新时历史记录丢失的问题。

Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@CLAassistant

CLAassistant commented Oct 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@crazylxr crazylxr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed functional history updates, batched navigation, reset/update ordering, redo invalidation, and history limits. The 18 focused useHistoryTravel tests pass; no blocking issues found.

Validation used the locally installed dependencies; a full build and full-suite coverage check were not run as part of this review.

@crazylxr
crazylxr merged commit 9187b81 into alibaba:master Oct 26, 2026
1 check passed
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.

3 participants