@@ -89,15 +89,16 @@ const App = () => {
8989
9090### Parameters
9191
92- | Parameter | type | description | default |
93- | ------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |
94- | ` maxHistory ` | number | The maximum number of history to keep | 10 |
95- | ` initialPatches ` | TravelPatches | The initial patches | {patches: [ ] ,inversePatches: [ ] } |
96- | ` initialPosition ` | number | The initial position of the state | 0 |
97- | ` autoArchive ` | boolean | Auto archive the state (see [ Archive Mode] ( #archive-mode ) for details) | true |
98- | ` enableAutoFreeze ` | boolean | Enable auto freeze the state, [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | false |
99- | ` strict ` | boolean | Enable strict mode, [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | false |
100- | ` mark ` | Mark<O, F>[ ] | The mark function , [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | () => void |
92+ | Parameter | type | description | default |
93+ | ------------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
94+ | ` maxHistory ` | ` number ` | The maximum number of history to keep | 10 |
95+ | ` initialPatches ` | ` TravelPatches ` | The initial patches | {patches: [ ] ,inversePatches: [ ] } |
96+ | ` initialPosition ` | ` number ` | The initial position of the state | 0 |
97+ | ` autoArchive ` | ` boolean ` | Auto archive the state (see [ Archive Mode] ( #archive-mode ) for details) | true |
98+ | ` enableAutoFreeze ` | ` boolean ` | Enable auto freeze the state, [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | false |
99+ | ` strict ` | ` boolean ` | Enable strict mode, [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | false |
100+ | ` mark ` | ` Mark<O, F>[] ` | The mark function , [ view more] ( https://github.com/unadlib/mutative?tab=readme-ov-file#createstate-fn-options ) | () => void |
101+ | ` patchesOptions ` | ` boolean | PatchesOptions ` | Customize JSON Patch format. Supports ` { pathAsArray: boolean } ` to control path format. See [ Mutative patches docs] ( https://mutative.js.org/docs/api-reference/create#patches ) | ` true ` (enable patches) |
101102
102103### Returns
103104
@@ -187,9 +188,12 @@ In manual archive mode, you control when state changes are recorded to history u
187188** Use Case 1: Batch multiple changes into one history entry**
188189
189190``` jsx
190- const [state , setState , controls ] = useTravel ({ count: 0 }, {
191- autoArchive: false
192- });
191+ const [state , setState , controls ] = useTravel (
192+ { count: 0 },
193+ {
194+ autoArchive: false ,
195+ }
196+ );
193197
194198// Multiple setState calls across different renders
195199setState ({ count: 1 }); // Temporary change (not in history yet)
@@ -217,6 +221,7 @@ function handleSave() {
217221```
218222
219223The key difference:
224+
220225- ** Auto archive** : Each ` setState ` = one undo step
221226- ** Manual archive** : ` archive() ` call = one undo step (can include multiple ` setState ` calls)
222227
0 commit comments