I have mapping function like this:
function MyFunction({rows}) {
return(
rows
.map((info, index) => (
<td key = {someNum}>
<p>some info</p>
</td>
)));
}
and I want to add something that will create new rows after the index hits five:
function MyFunction({rows}) {
return(
rows
.map((info, index) => (
{(index+1 %5 === 0 || index === 0) && <tr>}
<td key = {someNum}>
<p>some info</p>
</td>
{(index+1 %5 === 0) && </tr>}
)));
}
I can’t get it to work, any ideas?
I’ve tried a lot of different syntax inside those curly brackets, but cant seem to figure out how to do it.
2
Answers
I think you are missing a return statement
if you use arrow function like
but if you use it like that
In your case