concept visitor in category react

appears as: A visitor, visitor, The visitor
React Hooks in Action

This is an excerpt from Manning's book React Hooks in Action.

But updating state and re-rendering is not a one-off task. A visitor using your app is likely to cause a multitude of state changes and React will need to repeatedly ask your components for the latest UI that represents the latest state values. It’s your components’ job to convert their state and props (the properties passed to them) into a description of their user interface. React then takes those UI descriptions and schedules updates to the DOM (the browser’s Document Object Model) where necessary. At various points this book uses cycle diagrams and accompanying step-by-step descriptions to highlight the repeating nature of these updates, as shown in the Cycle Diagrams section on pages mm and nn.

But, to get a better feel for how the function component and its hooks manage all the pieces, let’s run through the steps for the component as it renders and re-renders and a visitor to the page selects a user from the list. We look at two key scenarios:

  • The visitor first loads the page. There is no user value in local storage. The visitor selects a user from the list.
  • The visitor refreshes the page. There is a user value in local storage.