Hi guys I'm trying to filter out the first iteration of the map function because its undefined and I don't want it to show,
the code is this:
const data = this.state.arr.map((r, index) => (
<tr key={index}>
<th>{index}</th>
<th>{r.formName}</th>
<th>{this.state.numofSub} </th>
<th>
<Link to={`/submitPage/${r._id}`}>Submit PageLink</Link>
</th>
<th>
<Link to={`/submissionPage/${r._id}`}>Submission page Link </Link>
</th>
</tr>
));
I tried adding if statement before the render like so:
const data = this.state.arr.map((r, index) => (
if(r._id){
<tr key={index}>
<th>{index}</th>
<th>{r.formName}</th>
<th>{this.state.numofSub} </th>
<th>
<Link to={`/submitPage/${r._id}`}>Submit PageLink</Link>
</th>
<th>
<Link to={`/submissionPage/${r._id}`}>Submission page Link </Link>
</th>
</tr>
)}
else return NULL
);
but it won't compile, can someone tell me how is the proper way to do this? to be clear I just want to check that the r._id has something in it, if it doesn't then I don't want it to show.