use-good-hooks 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -211,13 +211,13 @@ import { useStateHistory } from 'use-good-hooks/use-state-history';
211
211
 
212
212
  const TextEditor = () => {
213
213
  const {
214
- state,
215
- setState,
214
+ canRedo,
215
+ canUndo,
216
216
  history,
217
- back,
218
- forward,
219
- canBack,
220
- canForward,
217
+ redo,
218
+ setState,
219
+ state,
220
+ undo
221
221
  } = useStateHistory('', { capacity: 10 });
222
222
 
223
223
  return (
@@ -229,8 +229,8 @@ const TextEditor = () => {
229
229
  cols={50}
230
230
  />
231
231
  <div>
232
- <button onClick={back} disabled={!canBack}>Undo</button>
233
- <button onClick={forward} disabled={!canForward}>Redo</button>
232
+ <button onClick={undo} disabled={!canUndo}>Undo</button>
233
+ <button onClick={redo} disabled={!canRedo}>Redo</button>
234
234
  </div>
235
235
  <p>History (last {history.length} changes):</p>
236
236
  <pre>{JSON.stringify(history, null, 2)}</pre>
@@ -248,13 +248,13 @@ const TextEditor = () => {
248
248
  #### Returns
249
249
 
250
250
  - Object with:
251
- - `state`: The current state value
252
- - `setState`: Function to update the state and record history
251
+ - `canRedo`: Boolean indicating if redo is possible
252
+ - `canUndo`: Boolean indicating if undo is possible
253
253
  - `history`: Array of all recorded states
254
- - `back`: Function to move to the previous state (undo)
255
- - `forward`: Function to move to the next state (redo)
256
- - `canBack`: Boolean indicating if undo is possible
257
- - `canForward`: Boolean indicating if redo is possible
254
+ - `redo`: Function to move to the next state (redo)
255
+ - `set`: Function to update the state and record history
256
+ - `state`: The current state value
257
+ - `undo`: Function to move to the previous state (undo)
258
258
 
259
259
  ### `useDistinct`
260
260
 
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "test": "vitest",
50
50
  "test:coverage": "vitest --coverage"
51
51
  },
52
- "version": "1.0.24"
52
+ "version": "1.0.26"
53
53
  }