...

/

Passing Data through our React Code

Passing Data through our React Code

Let's pass data through React in this lesson.

We'll cover the following...

The Row component

Following our change through, the VenueBody component doesn’t change much, it merely takes in the extra values and passes them along, giving each row its corresponding RowData:

Press + to interact
import * as React from "react"
import Row from "components/row"
import { VenueData } from "components/venue"
interface VenueBodyProps {
concertId: number
rowCount: number
seatsPerRow: number
ticketsToBuyCount: number
venueData: VenueData
}
const rowItems = ({
concertId,
rowCount,
seatsPerRow,
ticketsToBuyCount,
venueData,
}) => {
const rowNumbers = Array.from(Array(rowCount).keys())
return rowNumbers.map((rowNumber: number) => (
<Row
concertId={concertId}
key={rowNumber}
rowData={venueData[rowNumber]}
rowNumber={rowNumber}
seatsPerRow={seatsPerRow}
ticketsToBuyCount={ticketsToBuyCount}
/>
))
}
export const VenueBody = (props: VenueBodyProps): React.ReactElement => {
return (
<table className="table">
<tbody>{rowItems(props)}</tbody>
</table>
)
}
export default VenueBody

The Row component carries a lot of load here. It maintains a client-side status of each seat that is based on its ticket status and also the number of tickets the user ...