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.
- package/README.md +14 -14
- 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
|
-
|
|
215
|
-
|
|
214
|
+
canRedo,
|
|
215
|
+
canUndo,
|
|
216
216
|
history,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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={
|
|
233
|
-
<button onClick={
|
|
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
|
-
- `
|
|
252
|
-
- `
|
|
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
|
-
- `
|
|
255
|
-
- `
|
|
256
|
-
- `
|
|
257
|
-
- `
|
|
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