I wrote a function in REACTJS that helps me to read a JSON-File and to display the content of the JSON-File. When I use the code of the function inside of a body the display of the content works fine. But now i want to use the function to fill a table with the content of the JSON and it wont work – the page stays empty. Thank you in advance!
The Function:
JavaScript
x
16
16
1
function FillData() {
2
<div className="App">
3
{
4
Data.map( datan => {
5
return(
6
<div className="box">
7
8
{datan.personalActivationWord}
9
10
</div>
11
)
12
} )
13
}
14
</div>
15
}
16
Trying to use it to fill a table (Tabledata for Setting1):
JavaScript
1
31
31
1
function Table() {
2
return (
3
<div className={navto.table}>
4
<div className={navto.header}>HMI</div>
5
<FillData />
6
<table className>
7
<tr>
8
<th>Setting</th>
9
<th>Wert</th>
10
<th>Status</th>
11
</tr>
12
<tr>
13
<td>Setting1</td>
14
<td><FillData /></td>
15
<td>Aktualisiert vor 3 Sek.</td>
16
</tr>
17
<tr>
18
<td>Setting2</td>
19
<td>AKTIV</td>
20
<td>Aktualisiert vor 3 Sek.</td>
21
</tr>
22
<tr>
23
<td>Setting3</td>
24
<td>AKTIV</td>
25
<td>Aktualisiert vor 3 Sek.</td>
26
</tr>
27
</table>
28
</div>
29
)
30
}
31
Advertisement
Answer
You are not returning anything in your FillData
function.
JavaScript
1
16
16
1
function FillData() {
2
return <div className="App">
3
{
4
Data.map( datan => {
5
return(
6
<div className="box">
7
8
{datan.personalActivationWord}
9
10
</div>
11
)
12
} )
13
}
14
</div>
15
}
16