Skip to content

Commit 86266a3

Browse files
committed
Merge branch 'garrett/statecontexttest' of https://github.com/oslabs-beta/ReacType-v15 into mike/statecontexttest
2 parents c3fb56f + 846c4c5 commit 86266a3

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

app/src/components/App.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@ import Cookies from 'js-cookie';
1212
//redux toolkit addition
1313
import { useSelector, useDispatch } from 'react-redux';
1414
import { setInitialState, toggleLoggedIn, configToggle } from '../redux/reducers/slice/appStateSlice';
15+
1516
// Intermediary component to wrap main App component with higher order provider components
1617
export const App = (): JSX.Element => {
1718
// const [state, dispatch] = useReducer(reducer, initialState);
1819
const state = useSelector(store => store.appState);
1920
const dispatch = useDispatch();
21+
console.log("loaded right away")
2022
// checks if user is signed in as guest or actual user and changes loggedIn boolean accordingly
21-
if (window.localStorage.getItem('ssid') !== 'guest') {
22-
// state.isLoggedIn = true;
23-
dispatch(toggleLoggedIn())
24-
}
23+
useEffect(()=>{
24+
if (window.localStorage.getItem('ssid') !== 'guest') {
25+
// state.isLoggedIn = true;
26+
dispatch(toggleLoggedIn())
27+
}
28+
},[])
29+
2530
// else {
2631
// state.isLoggedIn = false;
2732
// }
@@ -63,7 +68,7 @@ export const App = (): JSX.Element => {
6368
}
6469
});
6570
}
66-
}, []);
71+
}, [state.isLoggedIn]);
6772
useEffect(() => {
6873
// provide config properties to legacy projects so new edits can be auto saved
6974
// if (state.config === undefined) {

app/src/components/StateManagement/CreateTab/CreateContainer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { useEffect, useState } from 'react';
2-
import { useStore } from 'react-redux';
2+
// import { useStore } from 'react-redux';
33
import Grid from '@mui/material/Grid';
44
import StatePropsPanel from './components/StatePropsPanel';
55

66
const CreateContainer = ({isThemeLight, data}) => {
7-
const store = useStore();
8-
const [state, setState] = useState([]);
7+
// const store = useStore();
8+
// const [state, setState] = useState([]);
99

10-
//pulling data from redux store
11-
useEffect(() => {
12-
setState(store.getState().contextSlice);
13-
}, []);
10+
// //pulling data from redux store
11+
// useEffect(() => {
12+
// setState(store.getState().contextSlice);
13+
// }, []);
1414

1515
return (
1616
<Grid container display="flex" justifyContent="stretch" flexDirection="column">

app/src/components/login/SignUp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const useStyles = makeStyles(theme => ({
5252
alignItems: 'center'
5353
},
5454
avatar: {
55-
margin: theme.spacing(1),
55+
// margin: theme.spacing(1),
5656
backgroundColor: '#3EC1AC'
5757
},
5858
form: {

app/src/components/right/ComponentPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ComponentPanel = ({isThemeLight}): JSX.Element => {
2525

2626
const state = useSelector(store => store.appState);
2727
const dispatch = useDispatch();
28-
console.log('state', state)
28+
2929

3030
//state hooks for inputted component name, component id and array of components
3131
const [errorStatus, setErrorStatus] = useState(false);

app/src/components/right/LoginButton.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { useHistory } from 'react-router-dom';
55
import makeStyles from '@mui/styles/makeStyles';
66
import StateContext from '../../context/context';
77
import { useSelector } from 'react-redux';
8+
import { useDispatch } from 'react-redux';
9+
import { toggleLoggedIn } from '../../redux/reducers/slice/appStateSlice';
810

911
export default function LoginButton() {
1012
const history = useHistory();
1113
// const [state,] = useContext(StateContext);
1214
const state = useSelector(store => store.appState)
15+
const dispatch = useDispatch();
1316
// const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
1417
// e.preventDefault();
1518
// // clear local storage
@@ -29,6 +32,7 @@ export default function LoginButton() {
2932
window.location.href = '/index-prod.html'
3033
} else {
3134
window.location.href = 'http://localhost:8080/#/login';
35+
dispatch(toggleLoggedIn())
3236
}
3337
}
3438
if (state.isLoggedIn) {

0 commit comments

Comments
 (0)