Skip to content

Commit e76fcd6

Browse files
authored
Merge pull request #8 from oslabs-beta/featurekelvin
changes to RTK for actionContainer and action component
2 parents 71c4d40 + 4fb32f6 commit e76fcd6

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/app/FrontendTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export interface ActionProps {
159159
last: boolean;
160160
index: number;
161161
sliderIndex: number;
162-
dispatch: (a: { type: string; payload: unknown }) => void;
162+
// dispatch: (a: { type: string; payload: unknown }) => void;
163163
displayName: string;
164164
componentName: string;
165165
componentData: { actualDuration: number } | undefined;

src/app/components/Action.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import React from 'react';
66
import ReactHover, { Trigger, Hover } from 'react-hover';
7-
import { changeView, changeSlider } from '../actions/actions';
7+
import { changeView, changeSlider } from '../RTKslices';
88
import { ActionProps, OptionsCursorTrueWithMargin } from '../FrontendTypes';
9+
import { useDispatch } from 'react-redux';
910

1011
/*
1112
This render's the individual snapshot components on the left side column
@@ -27,13 +28,18 @@ import { ActionProps, OptionsCursorTrueWithMargin } from '../FrontendTypes';
2728
*/
2829

2930
const Action = (props: ActionProps): JSX.Element => {
31+
32+
//here we are adding useSelector and useDispatch for RTK state conversion
33+
const dispatch = useDispatch();
34+
3035
// We destructure the 'props' that were passed into this component
3136
const {
3237
selected, // boolean on whether the current index is the same as the viewIndex in 'ActionContainer'
3338
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) in 'ActionContainer'
3439
index, // from snapshot.index in "ActionContainer's" 'hierarchyArr'
3540
sliderIndex, // from tabs[currentTab] object in 'ActionContainer'
36-
dispatch,
41+
//commented out dispatch that was prop drilled as conversion to RTX might invalidate need for prop drilling to access dispatch
42+
// dispatch,
3743
displayName, // from snapshot.displayName in "ActionContainer's" 'hierarchyArr'
3844
componentData, // from snapshot.componentData in "ActionContainer's" 'hierarchyArr'
3945
viewIndex, // from tabs[currentTab] object in 'ActionContainer'

src/app/containers/ActionContainer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ function ActionContainer(props): JSX.Element {
137137
componentData={snapshot.componentData}
138138
selected={selected}
139139
last={last}
140-
dispatch={dispatch}
140+
//not sure if we need to prop drill dispatch anymore as we can import it directly within action component
141+
//line 142 commented out for this reason above
142+
// dispatch={dispatch}
141143
sliderIndex={sliderIndex}
142144
handleOnkeyDown={handleOnKeyDown}
143145
viewIndex={viewIndex}

0 commit comments

Comments
 (0)