简体   繁体   English

在嵌套映射中反应本机jsx

[英]React native jsx in a nested map

Need help with nested maps. 需要有关嵌套地图的帮助。 Pretty confusing to figure out 很难弄清楚

      {
        sectorHeader.map((dutyPeriod) => (
          <Text style={Styles.heading} />
          dutyPeriod.dutyItems.map((dutyItem) => (
            <SectorCell
             flightNumber={`${dutyItem.flightLeg.scheduledFlightDesignator.airlineCode}${dutyItem.flightLeg.scheduledFlightDesignator.flightNumber}`}
             flightDate={dutyItem.flightLeg.departureTimes.scheduled.localTime}
            />
        ))))
      }

I get an error in the line "dutyPeriod.dutyItems.map((dutyItem) => (" because of the jsx in the previous line. How can i have a jsx when i have multiple maps? 由于上一行中的jsx,我在“ dutyPeriod.dutyItems.map((dutyItem)=>(”行中收到错误。当我有多个地图时,如何拥有jsx?

Error that I get 我得到的错误

Unexpected token, expected ,

{sectorHeader.map((dutyPeriod) => (
  <Text style={Styles.heading} />
   dutyPeriod.dutyItems.map((dutyItem) => (
   ^

surround js codes with {} in jsx codes: 在jsx代码中用{}包围js代码:

{
dutyPeriod.dutyItems.map((dutyItem) => (
        <SectorCell
         flightNumber={`${dutyItem.flightLeg.scheduledFlightDesignator.airlineCode}${dutyItem.flightLeg.scheduledFlightDesignator.flightNumber}`}
         flightDate={dutyItem.flightLeg.departureTimes.scheduled.localTime}
        />
    ))
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM