質問編集履歴
5
質問の解答
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,6 +126,10 @@
|
|
126
126
|
|
127
127
|
|
128
128
|
|
129
|
+
最新のプログラム
|
130
|
+
|
131
|
+
|
132
|
+
|
129
133
|
```
|
130
134
|
|
131
135
|
export default function CustomizedMenus({ categories, onClick }) {
|
@@ -198,11 +202,11 @@
|
|
198
202
|
|
199
203
|
>
|
200
204
|
|
201
|
-
{categories.map(category =>
|
205
|
+
{categories.map(category => {
|
202
206
|
|
203
207
|
const TagName = category.icon;
|
204
208
|
|
205
|
-
<StyledMenuItem onClick={() => onClick(to(category))}>
|
209
|
+
<StyledMenuItem onClick={() => onClick(to(category))}>##該当箇所
|
206
210
|
|
207
211
|
<ListItemIcon>
|
208
212
|
|
@@ -214,6 +218,6 @@
|
|
214
218
|
|
215
219
|
</StyledMenuItem>
|
216
220
|
|
217
|
-
)
|
221
|
+
})}
|
218
|
-
|
222
|
+
|
219
|
-
```
|
223
|
+
```
|
4
質問の解答
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,28 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
###エラー
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
Failed to compile.
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
./src/components/CustomizedMenus.js
|
22
|
+
|
23
|
+
Line 83:11: Expected an assignment or function call and instead saw an expression no-unused-expressions
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
Search for the keywords to learn more about each error.
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
13
35
|
### 該当のソースコード
|
14
36
|
|
15
37
|
変更前
|
@@ -180,7 +202,7 @@
|
|
180
202
|
|
181
203
|
const TagName = category.icon;
|
182
204
|
|
183
|
-
<StyledMenuItem onClick={() => onClick(to(category))}>
|
205
|
+
<StyledMenuItem onClick={() => onClick(to(category))}> ##エラー該当箇所
|
184
206
|
|
185
207
|
<ListItemIcon>
|
186
208
|
|
3
質問の解答
test
CHANGED
File without changes
|
test
CHANGED
@@ -106,7 +106,63 @@
|
|
106
106
|
|
107
107
|
```
|
108
108
|
|
109
|
+
export default function CustomizedMenus({ categories, onClick }) {
|
110
|
+
|
111
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
const handleClick = event => {
|
116
|
+
|
117
|
+
setAnchorEl(event.currentTarget);
|
118
|
+
|
119
|
+
};
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
const handleClose = () => {
|
124
|
+
|
125
|
+
setAnchorEl(null);
|
126
|
+
|
127
|
+
};
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
const to = category => (
|
132
|
+
|
133
|
+
category.id === '1'
|
134
|
+
|
135
|
+
? `/all`
|
136
|
+
|
137
|
+
: `/category/${category.id}`
|
138
|
+
|
139
|
+
);
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
return (
|
144
|
+
|
145
|
+
<div>
|
146
|
+
|
147
|
+
<Button
|
148
|
+
|
149
|
+
aria-controls="customized-menu"
|
150
|
+
|
151
|
+
aria-haspopup="true"
|
152
|
+
|
153
|
+
variant="contained"
|
154
|
+
|
155
|
+
color="primary"
|
156
|
+
|
157
|
+
onClick={handleClick}
|
158
|
+
|
159
|
+
>
|
160
|
+
|
161
|
+
ボタン
|
162
|
+
|
163
|
+
</Button>
|
164
|
+
|
109
|
-
<StyledMenu
|
165
|
+
<StyledMenu
|
110
166
|
|
111
167
|
id="customized-menu"
|
112
168
|
|
@@ -122,7 +178,7 @@
|
|
122
178
|
|
123
179
|
{categories.map(category => (
|
124
180
|
|
125
|
-
const TagName=
|
181
|
+
const TagName = category.icon;
|
126
182
|
|
127
183
|
<StyledMenuItem onClick={() => onClick(to(category))}>
|
128
184
|
|
2
質問の解答
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,6 +72,28 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
+
state
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
const initialState = {
|
80
|
+
|
81
|
+
categories: [
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
id: '1',
|
86
|
+
|
87
|
+
name: 'テレビ',
|
88
|
+
|
89
|
+
icon: 'CreateIcon'
|
90
|
+
|
91
|
+
},
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
75
97
|
|
76
98
|
|
77
99
|
### 試したこと
|
1
質問の解答
test
CHANGED
File without changes
|
test
CHANGED
@@ -79,3 +79,41 @@
|
|
79
79
|
?????の部分に
|
80
80
|
|
81
81
|
`${category.icon}`を入れてみましたがダメでした。
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
<StyledMenu
|
88
|
+
|
89
|
+
id="customized-menu"
|
90
|
+
|
91
|
+
anchorEl={anchorEl}
|
92
|
+
|
93
|
+
keepMounted
|
94
|
+
|
95
|
+
open={Boolean(anchorEl)}
|
96
|
+
|
97
|
+
onClose={handleClose}
|
98
|
+
|
99
|
+
>
|
100
|
+
|
101
|
+
{categories.map(category => (
|
102
|
+
|
103
|
+
const TagName=`${category.icon}`; ////////文法エラー
|
104
|
+
|
105
|
+
<StyledMenuItem onClick={() => onClick(to(category))}>
|
106
|
+
|
107
|
+
<ListItemIcon>
|
108
|
+
|
109
|
+
<TagName fontsize="small" />
|
110
|
+
|
111
|
+
</ListItemIcon>
|
112
|
+
|
113
|
+
<ListItemText primary={category.name} />
|
114
|
+
|
115
|
+
</StyledMenuItem>
|
116
|
+
|
117
|
+
))}
|
118
|
+
|
119
|
+
```
|