Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.44 KB

File metadata and controls

26 lines (21 loc) · 1.44 KB

Component Lifecycle / useEffect() Hook

Review, Research, and Discussion

  1. Why do we not need more .html pages in a multi-page React app?
    • react app pages re-render to update with new content
  2. If we wanted a component to show up on every page, where would we put it and why?
    • Inside the , because it is the parent router component so the component will render with all child components
  3. What does routing do with the components that were rendered when a new route is requested
    • ignores the other components
  4. What does props.children contain?
    • content between the opening and closing tags of the containing component
  5. How do useState() and this.setState() differ?
    • for useState(), deconstruction is used to define the state's variable and updating function

Vocab Terms

  • State Hook

    • can only be used inside function components, needs to be imported from react, lets you add state to function components, an initial value can be passed into the useState() parentheses
    • can declare a new state variable and function to update it via deconstruction:
      • const [count, setCount] = useState(0);
    • source: https://reactjs.org/docs/hooks-state.html
  • Mounting and Un-Mounting