Skip to content

feat(core/hooks): add 'useHistory' hook#338

Closed
sukvvon wants to merge 2 commits into
toss:mainfrom
sukvvon:feat/use-history
Closed

feat(core/hooks): add 'useHistory' hook#338
sukvvon wants to merge 2 commits into
toss:mainfrom
sukvvon:feat/use-history

Conversation

@sukvvon
Copy link
Copy Markdown
Contributor

@sukvvon sukvvon commented Mar 8, 2026

Overview

Add useHistory hook that tracks the change history of a value and provides undo/redo functionality.

  • setValue records a new value in the history stack
  • undo / redo navigate through past values
  • canUndo / canRedo indicate navigation availability
  • clear resets the history to the current value
  • capacity option limits the maximum number of history entries
  • Uses functional state updates to prevent stale closure issues
  • SSR-safe, 100% test coverage (13 tests)

Checklist

  • Did you write the test code?
  • Have you run yarn run fix to format and lint the code and docs?
  • Have you run yarn run test:coverage to make sure there is no uncovered line?
  • Did you write the JSDoc?

@sukvvon sukvvon force-pushed the feat/use-history branch from 7ffd0da to 7b98379 Compare March 8, 2026 18:39
@kimyouknow
Copy link
Copy Markdown
Collaborator

Thank you for this well-implemented hook! The code quality is excellent.

After discussion with @zztnrudzz13 , we've decided useHistory falls outside the library's scope. Undo/redo history management reflects a specific domain pattern rather than a primitive building block — it embeds assumptions about how state history should be structured, which varies by use case.

Our goal is to provide primitives that users compose freely, rather than opinionated domain-level abstractions.

We're closing several PRs with the same rationale — see #343, #233 for similar decisions.

If you see it differently or have thoughts on this, we'd love to hear them. We appreciate the effort and welcome contributions in other areas!

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.

2 participants