Skip to content

Commit dffbf80

Browse files
Christopher StamperChristopher Stamper
authored andcommitted
Finished migrating Diff to RTK
1 parent 93aa862 commit dffbf80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/app/components/Diff.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { diff, formatters } from 'jsondiffpatch';
33
import ReactHtmlParser from 'react-html-parser';
44
import { useStoreContext } from '../store';
55
import { DiffProps, StatelessCleaning } from '../FrontendTypes';
6+
import { useSelector } from 'react-redux';
67

78
/**
89
* Displays tree showing two specific versions of tree:
@@ -16,8 +17,9 @@ function Diff(props: DiffProps): JSX.Element {
1617
snapshot, // snapshot from 'tabs[currentTab]' object in 'MainContainer'
1718
show // boolean that is dependent on the 'Route' path; true if 'Route' path === '/diffRaw'
1819
} = props;
19-
const [mainState] = useStoreContext(); // useStoreContext() returns our global state object (which was initialized as 'initialState' in 'App.tsx')
20-
const { currentTab, tabs } = mainState; // 'currentTab' (type: number) and 'tabs' (type: object) are destructured from 'mainState'
20+
// const [mainState] = useStoreContext(); // useStoreContext() returns our global state object (which was initialized as 'initialState' in 'App.tsx')
21+
// const { currentTab, tabs } = mainState; // 'currentTab' (type: number) and 'tabs' (type: object) are destructured from 'mainState'
22+
const { currentTab, tabs } = useSelector((state: any) => state.main);
2123
const { snapshots, viewIndex, sliderIndex } = tabs[currentTab];
2224

2325
let previous: unknown// = (viewIndex !== -1) ? snapshots[viewIndex - 1] : previous = snapshots[sliderIndex - 1]

0 commit comments

Comments
 (0)