I want to load components but it shows a problem that the components with the same key, but I mapped on selectedGroups and gave gr.id as a key it worked before the first version:
sharingTabs = selectedGroups.map(gr => (
<ExpansionPanel>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={classes.heading}>{gr.name}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Grid container spacing={16}>
<Grid item xs>
<SharingSpacesTabs />
</Grid>
</Grid>
</ExpansionPanelDetails>
</ExpansionPanel>
));
But then I wanted to send the index in a props that's why I added another map inside the map that's what caused the problem of call back function and I aded return
sharingTabs = selectedGroups.map(function(gr) {
const indexs = groups.map((group, index) => {
if ((group.sharingspace.element = gr.id)) {
return index;
}
});
return (
<ExpansionPanel key={gr.id}>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={classes.heading}>{gr.name}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Grid container spacing={16}>
<Grid item xs>
<SharingSpacesTabs id={gr.id} index={indexs[0]} />
</Grid>
</Grid>
</ExpansionPanelDetails>
</ExpansionPanel>
);
});
Could you please help me find a solution I need it and thank you.