UNPKG

react-diff-view

Version:

A git diff component to consume the git unified diff output.

24 lines 733 B
import { useEffect } from 'react'; import { getChangeKey } from '../utils'; import { useCollection } from './helpers'; export default function useChangeSelect(hunks, { multiple = false } = {}) { const { collection, clear, toggle, only } = useCollection(); // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(clear, [hunks]); return [ collection, ({ change }) => { if (!change) { return; } const changeKey = getChangeKey(change); if (multiple) { toggle(changeKey); } else { only(changeKey); } }, ]; } //# sourceMappingURL=useChangeSelect.js.map