I suspect you might be aware of this but here goes. If one follows the book, the end of ch 9 will result in errors from the useEffect
call in Venue: Started GET "/tickets.json?concert_id=undefined"
. The reader should be able to figure this out, but the required changes aren’t explicitly listed in the text:
wherever Venue is initiated: packs/venue_display.js didn’t work for me so I’m using packs/application.js (props no longer hard-coded and add concertId):
<Venue
rows={parseInt(element.dataset.rows, 10)}
seatsInRow={parseInt(element.dataset.seatsInRow, 10)}
concertId={parseInt(element.dataset.concertId, 10)}
/>
concerts/show.html.erb (add data attributes):
<div id="react-element"
data-rows="<%= @concert.venue.rows %>"
data-seats-in-row="<%= @concert.venue.seats_per_row %>"
data-concert-id="<%= @concert.id %>">
</div>
Edit: I just noticed there’s bit of a naming mismatch between seats_per_row (Rails) and seatsInRow (React). I figured I’d point that out to you if you weren’t aware.