質問編集履歴
2
指摘内容を反映したコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,6 +126,68 @@
|
|
126
126
|
|
127
127
|
```
|
128
128
|
|
129
|
+
初学者で知識が浅いので、ご教授いただけると嬉しいです。
|
129
130
|
|
130
131
|
|
132
|
+
|
133
|
+
### クラスコンポーネントの型定義
|
134
|
+
|
135
|
+
```js
|
136
|
+
|
137
|
+
class ListsContainer extends Component<{}, { lists: ListData[] }> {
|
138
|
+
|
139
|
+
constructor(props) {
|
140
|
+
|
141
|
+
super(props);
|
142
|
+
|
143
|
+
this.state = {
|
144
|
+
|
145
|
+
lists: [],
|
146
|
+
|
147
|
+
};
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
componentDidMount() {
|
152
|
+
|
153
|
+
axios
|
154
|
+
|
155
|
+
.get('http://localhost:3001/api/v1/lists.json')
|
156
|
+
|
131
|
-
|
157
|
+
.then((response) => {
|
158
|
+
|
159
|
+
console.log(response);
|
160
|
+
|
161
|
+
this.setState({
|
162
|
+
|
163
|
+
lists: response.data,
|
164
|
+
|
165
|
+
});
|
166
|
+
|
167
|
+
})
|
168
|
+
|
169
|
+
.catch((error) => console.log(error));
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
render() {
|
174
|
+
|
175
|
+
return (
|
176
|
+
|
177
|
+
<div className='Lists-container'>
|
178
|
+
|
179
|
+
{this.state.lists.map((list) => {
|
180
|
+
|
181
|
+
return <List list={list} key={list.id} />;
|
182
|
+
|
183
|
+
})}
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
);
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
```
|
1
タグの修正
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|