0.2.8 • Published 5 years ago
@bearjam/tom
Licence
MIT
Version
0.2.8
Deps
5
Size
89 kB
Vulns
3
Weekly
0
Usage
yarn add @bearjam/tom
import { withUndoableReducer } from "@bearjam/tom"
const initialState: State = {
// ...
}
const reducer = (state: State, action: Action): State => {
// ...
}
export const useCanvasStore = create(withUndoableReducer(reducer, initialState))
Then you can call this hook in your React app:
const [state, dispatch, undo, redo, canUndo, canRedo] = useCanvasStore(
store => [
store.state,
store.dispatch,
store.undo,
store.redo,
store.canUndo,
store.canRedo,
],
shallow
)