I was experimenting with fragments and was trying to dynamically load data onto a table. I am not getting any error but the table isn't displaying on the webpage. Please find my attached code snippets below. There are 3 files called App.js, FragmentDemo.js (I've declared the table and the header here) and FragmentChild.js (The table data will be sent from an array of data)
//**App.js**
import logo from './logo.svg';
import './App.css';
import MountLife from './components/MountLifeCycle'
import Fragment from './components/Fragments/FragmentDemo'
function App() {
return (<div className="App">
<Fragment />
</div>)
}
export default App;
//**FragmentDemo.js**
import React from 'react'
import FragChild from './FragChild'
function FragmentDemo() {
return (
<div>
<table>
<tr>
<th>id</th>
<th>Name</th>
<th>Company</th>
</tr>
<FragChild />
</table>
</div>
)
}
export default FragmentDemo
//**FragChild.js**
import React from 'react'
function FragChild() {
const list = [{
id: 1,
name: "P1",
company:"Google"
},
{
id: 2,
name: "P2",
company:"Microsoft"
},
{
id: 3,
name: "P3",
company:"Uber"
}
]
const paramList = list.map( elem => (
<tr key={elem.id}>
<td>{list.id}</td>
<td>{list.name}</td>
<td>{list.company}</td>
</tr>))
return (
<React.Fragment>
{paramList}
</React.Fragment>
)
}
export default FragChild