AI Features

Passing Data through our React Code

Let's pass data through React in this lesson.

We'll cover the following...

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

import * as React from "react"
import Row from "./row"
import { VenueData } from "./venue"
interface VenueBodyProps {
concertId: number
rows: number
seatsInRow: number
ticketsToBuy: number
venueData: VenueData
}
const rowItems = (props: VenueBodyProps) => {
const rowNumbers = Array.from(Array(props.rows).keys())
return rowNumbers.map(rowNumber => (
<Row
key={rowNumber}
rowNumber={rowNumber}
seatsInRow={props.seatsInRow}
ticketsToBuy={props.ticketsToBuy}
concertId={props.concertId}
rowData={props.venueData[rowNumber]}
/>
))
}
export const VenueBody = (props: VenueBodyProps) => {
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, which is based on its ticket ...