Reputation: 121
This may be a simple fix but I'm new to react so I appologize in advance. I have nested data that I would like to display on a list. The data is being pulled and displayed below.
data: [
{
"id": 1,
"domain_url": "localhost",
"created_on": "2020-05-26",
"config": [
{
"test_name": "test",
"test_description": "test",
}
]
}
]
I can get the domain_url and created_on displaying just fine but nothing I've tried gets any of the config items to appear.
below is the current method I'm using.
<tbody>
{this.props.data.map((data) => (
<tr key={data.id}>
<td>{data.domain_url}</td>
<td>
{data.config.map((sub) => {
sub.test_name;
})}
</td>
<td>{data.created_on}</td>
<td>
...
how can I get the test name from the config array to display? Any help would be appreciated. Thank you!
Upvotes: 0
Views: 37
Reputation: 426
Your code looks right - I think you just need to add a ‘return’ in front of your ‘sub.test_name;’
Upvotes: 1