I have an Infinite Loader List component which renders array of data. I needed to aggregate my data (grouped by days), so I made two levels array:
list = {
[
{
group:'09-20',
data: [
content: 'content',
contentInfo: 'contentInfo'
]
},
{
group:'09-21',
data: [
content: 'content',
contentInfo: 'contentInfo'
]
},
]
// and so on...
}
Is there a way to render this? I tried to map the second array (called data here) in renderRow
function, but the result is buggy scrolling (data flickers because of rendering, and loadMoreRows
func is not triggered)
renderRow
:
renderRow = ({ index, key, style }) => {
let content;
if (!this.state.results[index]) content = <ActivityLogRowLoading />;
else {
const data = this.state.results[index].data.map(element => (
<Element>
<Content>{element.description}</Content>
<Date>
{moment(element.created).format('YYYY-MM-DD HH:mm:ss')}
</Date>
</Element>
));
content = (
<div>
{this.state.results[index].group}
{data}
</div>
);
}
return (
<div key={key} style={style}>
{content}
</div>
);
};