WebDevSimplified / useful-custom-react-hooks

1.95k stars 687 forks source link

Bug in useStateWithHistory #12

Closed 3noix closed 3 years ago

3noix commented 3 years ago

At the first line of the "go" function, there is a problem with the second index check: with the current code it is not possible to go to the last state. It should be for example "if (index < 0 || index > historyRef.current.length-1) return".

WebDevSimplified commented 3 years ago

Good catch. This will be fixed in the next update I make to the library. I have 5 hooks I am planning to add in a week or so.