Skip to content

Commit b77a221

Browse files
committed
updated SwitchApp component to RTK
1 parent 34a53b3 commit b77a221

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/app/components/SwitchApp.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react';
22
import Select from 'react-select';
3-
import { useStoreContext } from '../store';
4-
import { setTab } from '../actions/actions';
3+
//commented out for RTK
4+
// import { useStoreContext } from '../store';
5+
import { setTab } from '../RTKslices';
6+
//importing these methods for RTK
7+
import { useSelector, useDispatch } from 'react-redux';
58

69
/*
710
This is the dropdown menu on the left column above the 'clear' button and the state snapshots list. It allows us to switch between which website/application we are currently working on.
@@ -10,8 +13,13 @@ import { setTab } from '../actions/actions';
1013
*/
1114

1215
const SwitchAppDropdown = (): JSX.Element => {
13-
const [{ currentTab, tabs }, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
14-
16+
//commented out to implement RTK
17+
// const [{ currentTab, tabs }, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
18+
//here we are adding useSelector and useDispatch for RTK state conversion
19+
const dispatch = useDispatch();
20+
const currentTab = useSelector((state: any) => state.main.currentTab)
21+
const tabs = useSelector((state: any) => state.main.tabs)
22+
1523
const tabsArray: {}[] = []; // tabsArray is an empty array that will take objects as it's elements
1624

1725
Object.keys(tabs).forEach((tab) => { // We populate our 'tabsArray' with objects derived from the 'tab' that is currently being iterated on.

0 commit comments

Comments
 (0)