dependency-graph-construction
Version:
A powerful tool to construct dependency graphs for JavaScript and TypeScript projects. Useful for project structure analysis and debugging.
21 lines (16 loc) • 743 B
JavaScript
import { useCallback } from 'react';
const useManageHistory = ({ currentInteractionIndex, nodesHistory, updateNodes, updateCurrentInteractionIndex }) => {
const showPreviousInteraction = useCallback(() => {
updateCurrentInteractionIndex(currentInteractionIndex - 1);
updateNodes(nodesHistory[currentInteractionIndex - 1].nodes);
}, [currentInteractionIndex, nodesHistory]);
const showNextInteraction = useCallback(() => {
updateCurrentInteractionIndex(currentInteractionIndex + 1);
updateNodes(nodesHistory[currentInteractionIndex + 1].nodes);
}, [currentInteractionIndex, nodesHistory]);
return {
showPreviousInteraction,
showNextInteraction,
};
};
export default useManageHistory;