質問編集履歴
1
store, actionの該当ソースコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -254,6 +254,72 @@
|
|
254
254
|
|
255
255
|
|
256
256
|
|
257
|
+
**store**
|
258
|
+
|
259
|
+
```
|
260
|
+
|
261
|
+
export const store = configureStore({
|
262
|
+
|
263
|
+
reducer: {
|
264
|
+
|
265
|
+
user: userReducer,
|
266
|
+
|
267
|
+
},
|
268
|
+
|
269
|
+
});
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
**action**
|
276
|
+
|
277
|
+
```
|
278
|
+
|
279
|
+
export const userSlice = createSlice({
|
280
|
+
|
281
|
+
name: 'user',
|
282
|
+
|
283
|
+
initialState:{
|
284
|
+
|
285
|
+
user: {uid:"", displayName: ""},
|
286
|
+
|
287
|
+
},
|
288
|
+
|
289
|
+
reducers: {
|
290
|
+
|
291
|
+
login: (state, action) => {
|
292
|
+
|
293
|
+
state.user = action.payload;
|
294
|
+
|
295
|
+
},
|
296
|
+
|
297
|
+
logout: (state) => {
|
298
|
+
|
299
|
+
state.user = {uid:"", displayName: ""};
|
300
|
+
|
301
|
+
},
|
302
|
+
|
303
|
+
//USER型のオブジェクトをreact componentからdispatchする際に受け取る
|
304
|
+
|
305
|
+
updateUserProfile: (state, action: PayloadAction<USER>) => {
|
306
|
+
|
307
|
+
//payload/displayNameをRedux/userステート/displayName属性に更新
|
308
|
+
|
309
|
+
state.user.displayName = action.payload.displayName;
|
310
|
+
|
311
|
+
state.user.photoUrl = action.payload.photoUrl;
|
312
|
+
|
313
|
+
},
|
314
|
+
|
315
|
+
},
|
316
|
+
|
317
|
+
});
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
257
323
|
### 試したこと
|
258
324
|
|
259
325
|
エラー内容から、Provider内にコンポーネントを格納する必要があるとのことですが、
|