So basically I have a list of objects like this:
const objects = [{name: ‘some name’, count: ‘how many of that name’}, …]
And I’m trying to render them like this:
{objects.map((item) => (
<Grid item key={item.name} xs={2} style={styles.count}>
<Typography
key={item.name}
align="right"
component="h1">
{`${item.name}: ${item.count}`}
</Typography>
</Grid>
))}
As you can imagine the result of this is something like this
name 1: 4 name 2: 4 name 3: 4
name 4: 4 name 4: 4
But I need something like this instead:
name 1: 4 name 3: 4 name 5: 4
name 2: 4 name 4: 4
3
Answers
I haven’t
css
trick for your question. but i have ajs
trick and It may help you :result of code is :
You can see domo on codesandbox
Have a look through React MUI Grid-auto-flow
Align your code and add style to parent container like this:
end result shall be like this
modify your code to use a
Grid
container with multiple rows 3 columns for each