Skip to content

Commit 606b08c

Browse files
committed
Semi-Done swapper
1 parent 8f70979 commit 606b08c

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

src/app/components/Actions/DropDown.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import Select from 'react-select';
22
import React, { useEffect, useState } from 'react';
33

4-
const DropDown = (): JSX.Element => {
5-
const [hook, setHook] = useState('useState');
6-
7-
const handleChange = (selectedHook: {hooks:string}) => {
8-
setHook(selectedHook);
9-
}
4+
interface DropDownProps {
5+
onChange: (selectedHook: string) => void;
6+
}
107

11-
const options = [
8+
const DropDown = ({onChange}: DropDownProps): JSX.Element => {
9+
10+
const options = [
1211
{value: 'useState', label: 'useState'},
1312
{value: 'useReducer', label: 'useReducer'},
1413
{value: 'useContext', label: 'useContext'}
1514
];
15+
const handleChange = (selectedHook: {value:string; label: string} | null) => {
16+
onChange(selectedHook.value);
17+
}
18+
19+
1620

1721
return (
1822
<Select

src/app/containers/ActionContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function ActionContainer(props: ActionContainerProps): JSX.Element {
224224
</a>
225225
<SwitchAppDropdown />
226226
{/* add new component here for dropdown menu for useStae/ useReducer- ragad */}
227-
<DropDown />
227+
<DropDown onChange={useState} />
228228
<div className='action-component exclude'>
229229
<Button
230230
className='clear-button'

src/app/containers/MainContainer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import TravelContainer from './TravelContainer';
55
import ButtonsContainer from './ButtonsContainer';
66
import ErrorContainer from './ErrorContainer';
77
import StateContainer from './StateContainer';
8+
import ReduceContainer from './ReduceContainer'
9+
import DropDown from '../components/Actions/DropDown';
810
import {
911
addNewSnapshots,
1012
initialConnect,
@@ -37,6 +39,7 @@ function MainContainer(): JSX.Element {
3739

3840
const [actionView, setActionView] = useState(true); // We create a local state 'actionView' and set it to true
3941

42+
const [hook, setHook] = useState('useState');
4043
// this function handles Time Jump sidebar view
4144
const toggleActionContainer = () => {
4245
setActionView(!actionView); // sets actionView to the opposite boolean value
@@ -208,6 +211,7 @@ function MainContainer(): JSX.Element {
208211
return (
209212
<div className='main-container'>
210213
<div id='bodyContainer' className='body-container'>
214+
<DropDown onChange={(value) => setHook(value)}/>
211215
<ActionContainer
212216
actionView={actionView}
213217
setActionView={setActionView}
@@ -229,6 +233,12 @@ function MainContainer(): JSX.Element {
229233
currLocation={currLocation}
230234
axSnapshots={axSnapshots}
231235
/>
236+
{hook === 'useReducer' && (
237+
<div className="state-container-container">
238+
<ReduceContainer />
239+
</div>
240+
)}
241+
232242
</div>
233243
) : null}
234244
{/* @ts-ignore */}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
const ReduceContainer = (): JSX.Element => {
4+
return (
5+
<div>
6+
hello
7+
</div>
8+
)
9+
}
10+
11+
export default ReduceContainer;

0 commit comments

Comments
 (0)