質問編集履歴
3
タイトルの誤記を訂正しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Redux Toolkit で useDispatch が実行できません |
|
1
|
+
Redux Toolkit で useDispatch が実行できません | React Hooks + Redux Toolkit + TypeScript
|
body
CHANGED
File without changes
|
2
期待される挙動を追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
```
|
11
11
|
Initial state: hoge
|
12
12
|
Action: fuga
|
13
|
-
Update state:
|
13
|
+
Update state: fuga
|
14
14
|
```
|
15
|
-
と
|
15
|
+
と期待出来るはずですが、以下の状態でございます。
|
16
16
|
|
17
17
|

|
18
18
|
|
1
ファイル名の記入を行いました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,7 +18,8 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
### 該当のソースコード
|
21
|
+
```
|
21
|
-
|
22
|
+
# pages/SignUp/index.tsx
|
22
23
|
import React from 'react';
|
23
24
|
import { useDispatch, useSelector } from "react-redux";
|
24
25
|
import { googleSignup } from "../../stores/auth";
|
@@ -44,7 +45,8 @@
|
|
44
45
|
|
45
46
|
export default SignUp
|
46
47
|
```
|
48
|
+
```
|
47
|
-
|
49
|
+
# stores/auth.ts
|
48
50
|
import { createSlice } from '@reduxjs/toolkit';
|
49
51
|
|
50
52
|
export type State = {
|
@@ -74,7 +76,8 @@
|
|
74
76
|
|
75
77
|
```
|
76
78
|
|
79
|
+
```
|
77
|
-
|
80
|
+
# /index.ts
|
78
81
|
import React from 'react';
|
79
82
|
import ReactDOM from 'react-dom';
|
80
83
|
import { Provider } from "react-redux";
|
@@ -97,7 +100,9 @@
|
|
97
100
|
);
|
98
101
|
```
|
99
102
|
|
103
|
+
```
|
100
|
-
|
104
|
+
# stores/index.ts
|
105
|
+
|
101
106
|
import { combineReducers } from "redux";
|
102
107
|
import { configureStore } from "@reduxjs/toolkit";
|
103
108
|
|
@@ -113,7 +118,6 @@
|
|
113
118
|
export type AppDispatch = typeof Store.dispatch
|
114
119
|
|
115
120
|
export default Store;
|
116
|
-
|
117
121
|
```
|
118
122
|
|
119
123
|
### 試したこと
|