MCPcopy Create free account
hub / github.com/danvk/webdiff / DiffView

Function DiffView

ts/DiffView.tsx:21–55  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

19}
20
21export function DiffView(props: Props) {
22 const {diffOptions, thinFilePair} = props;
23 const [filePair, setFilePair] = React.useState<FilePair | null>(null);
24
25 React.useEffect(() => {
26 (async () => {
27 const newFilePair = await getThickDiff(thinFilePair.idx);
28 setFilePair({
29 ...newFilePair,
30 idx: thinFilePair.idx,
31 });
32 })().catch((e: unknown) => {
33 console.error(e);
34 });
35 }, [thinFilePair, setFilePair]);
36
37 if (!filePair) {
38 return <div>Loading…</div>;
39 }
40
41 let diffEl;
42 if (filePair.is_image_diff) {
43 diffEl = <ImageDiff filePair={filePair} {...props} />;
44 } else {
45 diffEl = (
46 <CodeDiffContainer
47 filePair={filePair}
48 diffOptions={diffOptions}
49 normalizeJSON={props.normalizeJSON}
50 />
51 );
52 }
53
54 return diffEl;
55}

Callers

nothing calls this directly

Calls 1

getThickDiffFunction · 0.90

Tested by

no test coverage detected