Skip to content

Commit 18c5d5b

Browse files
committed
move GameScreen to App for the moment because it was mounted inside <form> tag and 2nd fetch executed all the time
1 parent a001edb commit 18c5d5b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

code/src/App.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import { combineReducers, configureStore } from '@reduxjs/toolkit'
44

55
import { games } from './reducers/games'
66
import StartScreen from 'components/StartScreen'
7+
import GameScreen from './components/GameScreen'
78

89
const reducer = combineReducers({ games: games.reducer })
910
const store = configureStore({ reducer })
1011

1112
export const App = () => {
1213
return (
1314
<Provider store={store}>
14-
<StartScreen/>
15+
<StartScreen/>
16+
<GameScreen />
1517
</Provider>
1618
)
1719
}

code/src/components/GameScreen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const GameScreen = ({ inputValue }) => {
1010

1111
const actions = useSelector(store => store.games.username.actions)
1212
// const games = useSelector(store => store.games)
13-
console.log(actions)
13+
//console.log(actions)
1414

1515
const dispatch = useDispatch()
1616

code/src/components/StartScreen.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const StartScreen = () => {
2828
placeholder="Type your name..."
2929
/>
3030
<button onClick={onFormSubmit}>Start</button>
31-
<GameScreen />
3231
</form>
3332
)
3433
}

code/src/reducers/games.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ export const CarryOnGame = (direction) => {
4848
body: JSON.stringify({
4949
username: getState().games.username,
5050
type: 'move',
51-
direction
51+
direction: direction
5252
}),
5353
})
5454
.then(res => res.json())
55-
// .then(data => console.log(data))
5655
.then(data => dispatch(games.actions.setGameStatus(data)))
5756
}
5857
}

0 commit comments

Comments
 (0)