You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/components/SwitchApp.tsx
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,10 @@
1
1
importReactfrom'react';
2
2
importSelectfrom'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';
5
8
6
9
/*
7
10
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';
10
13
*/
11
14
12
15
constSwitchAppDropdown=(): 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
functionexportHandler(snapshots: []): void{// function that takes in our tabs[currentTab] object to be exported as a JSON file. NOTE: TypeScript needs to be updated
12
14
constfileDownload: HTMLAnchorElement=document.createElement('a');// invisible HTML element that will hold our tabs[currentTab] object
@@ -43,8 +45,13 @@ function importHandler(dispatch: (a: unknown) => void): void { // function handl
const[selectedSpeed,setSpeed]=useState(speeds[1]);// create a new local state selectedSpeed and set it to the second element of the 'speeds' array (1.0x speed)
63
-
const[{ tabs, currentTab },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
64
-
const{ sliderIndex, playing }=tabs[currentTab];// we destructure the currentTab object
66
+
67
+
// const [{ tabs, currentTab }, 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
68
+
// const { sliderIndex, playing } = tabs[currentTab]; // we destructure the currentTab object
0 commit comments