Class-31 Reading: Hooks API


Class-31 Reading: Hooks API

Table of Contents

Reading, Research, and Discussion

1. Why do we not need more .html pages in a multi-page React app?

  • Because the beauty of React is that it is reactive. It is actively re drawing the html on the index.html, and this is how new pages are rendered.

2. If we wanted a component to show up on every page, where would we put it and why?

  • Outside the <BrowserRouter/>
  • Inside the <BrowserRouter />, outside a <Route />
  • Inside a <Route />
  • Option 2, We want all our content within the Browser Router, Because this handles all pages within the site. Now anything inside a Route will be only for that page, that route, so we want the code to be on the outside of it.

3. What does props.children contain?

  • This will give access to the children elements of a component. So if you do not auto close a component, like so <Header /> and you set it up like <Header> <p>something here</p> </Header> then you will gain access to those child elements.

Vocabulary Terms

  • Composition :
    • def: React, composition is a natural pattern of the component model
  • Children / Child Components :
    • def: Components that are nested within another component.
  • Hash Routing :
    • def: Hash router uses a hash in the URL to render a component
  • Link Routing :
    • def: Link router uses HTML5 history API to render a component.

Additional Resources

Bookmark / Skim