Answer the question
In order to leave comments, you need to log in
How to dynamically populate a grid with data?
Hello. Please tell me how can I solve the following problem. I have some json data.
{
"cards": [
{ "id": "1", "content": "Lorem ipsum dolor sit amet." },
{ "id": "2", "content": "Lorem ipsum dolor sit amet." },
{ "id": "3", "content": "Lorem ipsum dolor sit amet." },
{ "id": "4", "content": "Lorem ipsum dolor sit amet." },
{ "id": "5", "content": "Lorem ipsum dolor sit amet." },
{ "id": "6", "content": "Lorem ipsum dolor sit amet." },
{ "id": "7", "content": "Lorem ipsum dolor sit amet." },
{ "id": "8", "content": "Lorem ipsum dolor sit amet." },
{ "id": "9", "content": "Lorem ipsum dolor sit amet." },
{ "id": "10", "content": "Lorem ipsum dolor sit amet." },
{ "id": "11", "content": "Lorem ipsum dolor sit amet." }
]
}
// this.cardsData, это данные
ReactDOM.render(
<NewsFeedPreviewList
list={this.cardsData}
/>,
document.querySelector('[data-dc-news-feed-preview-ref="primary-wrapper"]'));
NewsFeedPreviewList.js
class NewsFeedPreviewList extends Component {
renderNewsFeedPreview = (list) => {
let template = null;
template = list.map((item, i) => {
return (
<PlayerCardRow
key={i}
item={item}
/>
);
});
return template;
}
render() {
return (
<ul className="news-feed-preview__layout">
{ this.renderNewsFeedPreview(this.props.list) }
</ul>
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question