質問するログイン新規登録

質問編集履歴

2

指摘内容を反映したコードを追記

2020/07/05 16:25

投稿

mune92283498
mune92283498

スコア11

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

タグの修正

2020/07/05 16:24

投稿

mune92283498
mune92283498

スコア11

title CHANGED
File without changes
body CHANGED
File without changes