Acquiring Data in React with useState

Now we are going to get our React page to also interact by making API calls to server. When last we left our React page in Dynamic Styled Components, it was displaying the seating information for one specific concert. What we’d like it to do now is get that seating information from the server and update it if it changes. This will use the fetch method we’ve already seen, as well as a new React hook called useEffect.

Updating the seating information involves adding the following features to the page:

  • When the React components load, they need to get the current seating status from the server.

  • That status needs to get passed down from the Venue component to the seat component that uses the status to display. ...

Get Modern Front-End Development for Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.