File tree 3 files changed +50
-1
lines changed
3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { useSelector } from 'react-redux'
3
+
4
+ const GameScreen = ( ) => {
5
+ const userActions = useSelector ( store => store . games . username )
6
+ // console.log(userActions)
7
+
8
+ const games = useSelector ( store => store . games . username . actions )
9
+ console . log ( games )
10
+
11
+ return (
12
+ < div >
13
+ < h3 > { userActions . description } </ h3 >
14
+ { /* <p>{games.description}</p> */ }
15
+ { /* {userActions.map(action => (
16
+ <button
17
+ key={action}
18
+ onClick=""
19
+ >
20
+ {action}
21
+ </button>
22
+ ))} */ }
23
+ </ div >
24
+ )
25
+ }
26
+
27
+ export default GameScreen
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, { useState } from 'react'
2
2
import { useDispatch } from 'react-redux'
3
3
4
4
import { games , createNewPlayer } from '../reducers/games'
5
+ import GameScreen from './GameScreen'
5
6
6
7
const StartScreen = ( ) => {
7
8
const [ inputValue , setInputValue ] = useState ( '' )
@@ -27,6 +28,7 @@ const StartScreen = () => {
27
28
placeholder = "Type your name..."
28
29
/>
29
30
< button onClick = { onFormSubmit } > Start</ button >
31
+ < GameScreen />
30
32
</ form >
31
33
)
32
34
}
Original file line number Diff line number Diff line change @@ -29,9 +29,29 @@ export const createNewPlayer = (username) => {
29
29
username : `${ username } `
30
30
} ) ,
31
31
} )
32
- . then ( ( res ) => res . json ( ) )
32
+ . then ( res => res . json ( ) )
33
33
. then ( data => dispatch ( games . actions . setUserName ( data ) ) )
34
34
}
35
35
}
36
36
37
+ // map over actions send in action ?
38
+ // type: 'move',
39
+ // direction: action.direction
40
+
41
+ /* export const CarryOnGame = () => {
42
+ return (dispatch) => {
43
+ fetch('https://wk16-backend.herokuapp.com/action', {
44
+ method: 'POST',
45
+ headers: {
46
+ 'Content-type': 'application/json'
47
+ },
48
+ body: JSON.stringify({
49
+ direction
50
+ }),
51
+ })
52
+ .then(res => res.json())
53
+ .then(data => dispatch(games.actions.setDescription(data)))
54
+ }
55
+ }
56
+ */
37
57
export default games
You can’t perform that action at this time.
0 commit comments