How to check any one array exist while map()?

0

I am trying to print data using array data and data1.

I have done this

{data?.data1?.map((ac1: any) => {
<component prop1={data} prop2={data1}>
 })}

this will only work if data & data1 exist. I want to allow with any one must exist. How to achieve that.

node.js reactjs typescript
2021-11-24 05:09:34
1

0
{!!data.data1.length && data.data1.map((ac1: any) => {
    <component prop1={data} prop2={data1}>
})}
2021-11-24 05:11:50

While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: stackoverflow.com/help/how-to-answer . Good luck
nima

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................