質問編集履歴

4

connectの追記

2018/07/20 23:37

投稿

AtsushiKamei
AtsushiKamei

スコア9

test CHANGED
File without changes
test CHANGED
@@ -120,6 +120,10 @@
120
120
 
121
121
  }
122
122
 
123
+
124
+
125
+ const store = createStore(reducer);
126
+
123
127
  ```
124
128
 
125
129
 
@@ -284,6 +288,28 @@
284
288
 
285
289
  }
286
290
 
291
+
292
+
293
+ const mapStateToProps = (store) => {
294
+
295
+ return {
296
+
297
+ page: store.page,
298
+
299
+ authInfo: store.authInfo,
300
+
301
+ authType: store.authType,
302
+
303
+ }
304
+
305
+ }
306
+
307
+
308
+
309
+ export default connect(mapStateToProps)(Login)
310
+
311
+
312
+
287
313
  ```
288
314
 
289
315
 

3

actionの追記

2018/07/20 23:37

投稿

AtsushiKamei
AtsushiKamei

スコア9

test CHANGED
File without changes
test CHANGED
@@ -88,6 +88,40 @@
88
88
 
89
89
  ```
90
90
 
91
+ ### 該当のソースコード (action.js)
92
+
93
+ ```
94
+
95
+ export const changePage = (page) => {
96
+
97
+ console.log('changePage action page:', page)
98
+
99
+ return {
100
+
101
+ type: 'CHANGE_PAGE',
102
+
103
+ page
104
+
105
+ }
106
+
107
+ }
108
+
109
+
110
+
111
+ export const changeAuthInfo = (authInfo) => {
112
+
113
+ return {
114
+
115
+ type: 'CHANGE_AUTH_INFO',
116
+
117
+ authInfo
118
+
119
+ }
120
+
121
+ }
122
+
123
+ ```
124
+
91
125
 
92
126
 
93
127
  ### 該当のソースコード (app.js)

2

storeにreducerのコードを追記

2018/07/20 04:20

投稿

AtsushiKamei
AtsushiKamei

スコア9

test CHANGED
File without changes
test CHANGED
@@ -50,6 +50,42 @@
50
50
 
51
51
  }
52
52
 
53
+
54
+
55
+ function reducer(state = initialState, action) {
56
+
57
+ switch (action.type) {
58
+
59
+ case 'CHANGE_PAGE':
60
+
61
+ console.log('redirecting:', action.page)
62
+
63
+ return {
64
+
65
+ ...state,
66
+
67
+ page: action.page
68
+
69
+ }
70
+
71
+ case 'CHANGE_AUTH_INFO':
72
+
73
+ return {
74
+
75
+ ...state,
76
+
77
+ authInfo: action.authInfo
78
+
79
+ }
80
+
81
+ default:
82
+
83
+ return state
84
+
85
+ }
86
+
87
+ }
88
+
53
89
  ```
54
90
 
55
91
 

1

補足説明の追記

2018/07/19 05:01

投稿

AtsushiKamei
AtsushiKamei

スコア9

test CHANGED
File without changes
test CHANGED
@@ -227,3 +227,9 @@
227
227
 
228
228
 
229
229
  初心者なので、拙い質問で申し訳ありませんが、よろしくお願いします。
230
+
231
+
232
+
233
+ ### 補足
234
+
235
+ <Field>や<Control>などはcssフレームワークのbloomerを使用しています。