I want to render a list of elements from an array of objects in react. However, it's not working properly.
My Datafile
export const PageBottomData = [
{
sectionName: "property1",
listOfLinks: [
{linkName: "value1", linkStatus: "inactive"},
{linkName: "value2", linkStatus: "inactive"},
]
},
{
sectionName: "property2",
listOfLinks: [
{linkName: "value1", linkStatus: "inactive"},
{linkName: "value2", linkStatus: "inactive"}
]
},
];
Though the data has been imported correctly( from console log), the data is not returned to the render method. I want to render a list of links whose name is taken from linkName attribute.
App.js
import React from 'react';
import {PageBottomData} from './PageBottomData';
class App extends React.Component {
sectionListGroup = (keyword) => {
const listItems = PageBottomData.map(item => {
if(item.sectionName === keyword)
item.linkOfList.map((link, idx) => {
<li key = {idx} className = "list-group-item">link.linkName</li>
})
});
return listItems;
}
render() {
return (
<ul className = "list-group list-group-flush">
{sectionListGroup("Discover")}
</ul>
);
}
export default App;
Error: 'sectionListGroup is undefined'