LoginSignup
2
1

More than 3 years have passed since last update.

Reactでmap型の要素をループしてテーブルを作成する

Posted at

コード

  • 要素数的なものは取れないのかな、、、
  • tableはテーブル全体
  • thはテーブルの見出し(table head cell)
  • tdはテーブル内のデータ(table data)
  • trはテーブルの横の定義(table row)
  • アロー関数のループの中でテーブルを定義する感じ
                    <div>
                        <table border="1" width="500" cellPadding="0">
                            <th>No</th>
                            <th>Name</th>
                            <th>Status</th>
                                {this.state.pods.map((pod) =>
                                    <tr>
                                        <td>{pod.id}</td>
                                        <td>{pod.metadata.name}</td>
                                        <td>{pod.status.phase}</td>
                                    </tr>
                                )}
                        </table>
                    </div>

画面

image.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1