diff --git a/package.json b/package.json index a121921..a4df654 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "use-travel", - "version": "0.1.2", + "version": "0.1.3", "description": "A React hook for state time travel with undo, redo, and reset functionalities.", "main": "dist/index.cjs.js", "unpkg": "dist/index.umd.js", diff --git a/rollup.config.ts b/rollup.config.ts index 6512992..257d8db 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -30,6 +30,7 @@ export default { sourcemap: true, globals: { mutative: 'Mutative', + react: 'React', }, exports: 'named', }, @@ -43,5 +44,5 @@ export default { }), terser(), ], - external: ['mutative'], + external: ['mutative', 'react'], }; diff --git a/src/index.ts b/src/index.ts index 0924240..4ce3394 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ type TravelPatches = { inversePatches: Patches[]; }; -type Options = { +type Options = { maxHistory?: number; initialPatches?: TravelPatches; } & MutativeOptions; @@ -76,9 +76,9 @@ type Result = [ /** * A hook to travel in the history of a state */ -export const useTravel = ( +export const useTravel = ( initialState: S, - { maxHistory = 10, initialPatches, ...options }: Options = {} + { maxHistory = 10, initialPatches, ...options }: Options = {} ) => { const resetRef = useRef(false); const [position, setPosition] = useMutative(-1);