@@ -9,24 +9,24 @@ Stores defined amount of previous state values and provides handles to travel th
99``` typescript
1010const [state, setState, stateHistory] = useStateWithHistory < S = undefined > (
1111 initialState ?: S | (()=> S ),
12- historyCapacity ?: number = 10 ,
12+ capacity ?: number = 10 ,
1313 initialHistory ?: S
1414);
1515```
1616
1717- ** ` state ` ** , ** ` setState ` ** and ** ` initialState ` ** are exactly the same with native React's ` useState ` hook;
18- - ** ` historyCapacity ` ** - amount of history entries that hold by storage;
19- - ** ` initialHistory ` ** - if defined it will be used as initial history value, otherwise history will equals ` [ initialState ] ` .
18+ - ** ` capacity ` ** - amount of history entries held by storage;
19+ - ** ` initialHistory ` ** - if defined it will be used as initial history value, otherwise history will equal ` [ initialState ] ` .
2020Initial state will not be pushed to initial history.
21- If entries amount is greater than ` historyCapacity ` parameter it wont be modified on init but will be trimmed on next ` setState ` ;
21+ If entries amount is greater than ` capacity ` parameter it won't be modified on init but will be trimmed on the next call to ` setState ` ;
2222- ** ` stateHistory ` ** - an object containing history state:
23- - ** ` history ` ** _ ` : S[] ` _ - an array holding history entries. _ I will have the same ref all the time so pe careful with that one!_ ;
23+ - ** ` history ` ** _ ` : S[] ` _ - an array holding history entries. _ It will have the same ref all the time so be careful with that one!_ ;
2424 - ** ` position ` ** _ ` : number ` _ - current position _ index_ in history;
2525 - ** ` capacity ` ** _ ` : number = 10 ` _ - maximum amount of history entries;
26- - ** ` back ` ** _ ` : (amount?: number) => void ` _ - go back in state history, it will cause ` setState ` invoke and component re-render.
26+ - ** ` back ` ** _ ` : (amount?: number) => void ` _ - go back in state history, it will cause ` setState ` to be invoked and component re-render.
2727 If first element of history reached, the call will have no effect;
28- - ** ` forward ` ** _ ` : (amount?: number) => void ` _ - go forward in state history, it will cause ` setState ` invoke and component re-render.
29- If last element of history reached, the call will have no effect;
28+ - ** ` forward ` ** _ ` : (amount?: number) => void ` _ - go forward in state history, it will cause ` setState ` to be invoked and component re-render.
29+ If last element of history is reached, the call will have no effect;
3030 - ** ` go ` ** _ ` : (position: number) => void ` _ - go to arbitrary position in history.
3131 In case ` position ` is non-negative ot will count elements from beginning.
3232 Negative ` position ` will cause elements counting from the end, so ` go(-2) ` equals ` go(history.length - 1) ` ;
0 commit comments