Skip to content

Instantly share code, notes, and snippets.

View clintandrewhall's full-sized avatar
⌨️
hacking away

Clint Andrew Hall clintandrewhall

⌨️
hacking away
View GitHub Profile
@clintandrewhall
clintandrewhall / use_undo_redo.ts
Created November 19, 2021 20:38
React Hook - undo/redo
import { useReducer, useCallback, Reducer } from 'react';
interface State<T = string> {
past: T[];
present: T;
future: T[];
}
interface Action<T> {
type: 'UNDO' | 'REDO' | 'SET' | 'CLEAR';