Skip to content

v0.4.0

Latest
Compare
Choose a tag to compare
@dmaskasky dmaskasky released this 11 Mar 22:20
· 3 commits to main since this release

Release Notes

Version 0.4.0 - 3/11/25

🛠 Improvements

  • **Merged withHistory and withUndo into **withHistory
    • Now tracks atom state history while also providing undo/redo functionality.
    • Supports resetting history via RESET DEMO
    • Simplifies API by combining state tracking and undo capabilities into a single function.

⚠️ Breaking Changes

  • withUndo has been removed.
    • Migration Guide: Replace withUndo(atom, limit) with withHistory(atom, limit).

Before:

import { useAtomValue } from 'jotai'
import { withUndo } from 'jotai-history'

const countAtom = atom(0)
const countWithUndo = withUndo(countAtom, 2)

function Component() {
  const countWithUndo = useAtomValue(countWithUndoAtom)
  return <button onClick={() => countWithUndo.undo()}>Undo</button>
}

After:

import { useSetAtom } from 'jotai'
import { UNDO, withHistory } from 'jotai-history'

const countAtom = atom(0)
const countWithHistory = withHistory(countAtom, 2)

function Component() {
  const setCountWithHistory = useSetAtom(countWithUndoAtom)
  return <button onClick={() => setCountWithHistory(UNDO)}>Undo</button>
}

🐛 Bug Fixes

  • Fixed edge cases related to undo/redo boundary conditions.

⚡ How to Upgrade

npm update jotai-history

Ensure your code is updated to use withHistory in place of the deprecated withUndo.

For detailed migration steps, refer to the updated documentation.


Thanks for using jotai-history! 🚀