質問編集履歴
2
指摘内容を反映したコードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -62,5 +62,36 @@
|
|
62
62
|
|
63
63
|
export default ListsContainer;
|
64
64
|
```
|
65
|
+
初学者で知識が浅いので、ご教授いただけると嬉しいです。
|
65
66
|
|
67
|
+
### クラスコンポーネントの型定義
|
68
|
+
```js
|
69
|
+
class ListsContainer extends Component<{}, { lists: ListData[] }> {
|
70
|
+
constructor(props) {
|
71
|
+
super(props);
|
72
|
+
this.state = {
|
73
|
+
lists: [],
|
74
|
+
};
|
75
|
+
}
|
76
|
+
componentDidMount() {
|
77
|
+
axios
|
78
|
+
.get('http://localhost:3001/api/v1/lists.json')
|
66
|
-
|
79
|
+
.then((response) => {
|
80
|
+
console.log(response);
|
81
|
+
this.setState({
|
82
|
+
lists: response.data,
|
83
|
+
});
|
84
|
+
})
|
85
|
+
.catch((error) => console.log(error));
|
86
|
+
}
|
87
|
+
render() {
|
88
|
+
return (
|
89
|
+
<div className='Lists-container'>
|
90
|
+
{this.state.lists.map((list) => {
|
91
|
+
return <List list={list} key={list.id} />;
|
92
|
+
})}
|
93
|
+
</div>
|
94
|
+
);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
```
|
1
タグの修正
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|