I tried to transfer a list but the screen went blank
<ul className='flex flex-col gap-2 font-bodyFont'>
{
listItem.map(item =>
item.listData.map(data => (
<li>{data}</li>
))
)
}
</ul>
a way to pass the data cleanly and without the white screen
3
Answers
Have you already tried to add the
key
prop to yourli
tags?If there is blank screen, then there must be error message showing in the console. Meanwhile you can change this code like this
Try using optional chaining. This will not through any error if listItem or listData is undefined or null
You can read more about optional chaining here
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining