需要有关嵌套地图的帮助。弄清楚相当混乱
{
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}
/>
))))
}
我在行“dutyPeriod.dutyItems.map((dutyItem)=&gt;(因为上一行中的jsx因为jcx)中出现错误。当我有多张地图时,我怎么能有一个jsx?
我得错误
Unexpected token, expected ,
{sectorHeader.map((dutyPeriod) => (
<Text style={Styles.heading} />
dutyPeriod.dutyItems.map((dutyItem) => (
^
答案 0 :(得分:0)
在jsx代码中使用{}环绕js代码:
{
dutyPeriod.dutyItems.map((dutyItem) => (
<SectorCell
flightNumber={`${dutyItem.flightLeg.scheduledFlightDesignator.airlineCode}${dutyItem.flightLeg.scheduledFlightDesignator.flightNumber}`}
flightDate={dutyItem.flightLeg.departureTimes.scheduled.localTime}
/>
))
}