I've followed this tutorial but the requirement is a bit different. I've a function getArrayList that should generate an array of ItemComponent. The returned component will receive the items prop that is an array.
function getArrayList(ItemComponent) {
return null // return a new component that renders an array of ItemComponent
}
class Link extends React.Component {
render() {
return <a href={ this.props.item.href }>{ this.props.item.text }</a>;
}
}
const LinkList = getArrayList(Link);
document.body.innerHTML = "<div id='root'></div>";
const rootElement = document.getElementById("root");
if(LinkList) {
let items = [
{ href:"https://www.yahoo.com", text:"Yahoo" },
{ href:"https://www.bing.com", text:"Bing" }
];
ReactDOM.render(<LinkList items={items} />, rootElement);
console.log(rootElement.innerHTML);
}
getArrayListthat returns an array of components that will receive items (links) as an array and populate list of links, it's like a list wrapper moduleLinkarray as it's children