Chapter 3: Writing Your First Application with React Hooks

  1. What is the best practice for folder structures in React?
    • Start with a simple structure at first and nest more deeply when needed. Do not spend too much time thinking about the file structure when starting a project.
  2. Which principle should we use when splitting up React components?
    • The single responsibility principle, which states that every component should have responsibility over a single encapsulated part of the functionality
  3. What does the map function do?
    • The map function applies a given function to all elements of an array and returns a new array with the results
  4. How does destructuring work, and when do we use it?
    • With destructuring, we can get properties from an object or elements from an array by specifying the structure and variable names on the left side of the assignment. We can use destructuring to get certain props in React components.
  5. How does the spread operator work, and when do we use it?
    • The spread operator inserts all properties of an object or all elements of an array at a certain point in another object/array. It can be used to create new arrays or objects or to pass on all properties of an object as props to a React component.
  6. How do we deal with input fields using React Hooks?
    • We create a State Hook for the input field value and define a handler function that sets the value
  7. Where should local State Hooks be defined?
    • Local State Hooks should always be defined in the component where they are used
  1. What is global state?
    • Global state is state that is used across multiple components throughout the whole application
  2. Where should global State Hooks be defined?
    • Global State Hooks should be defined as high up in the component tree as possible. In our case, we defined them in the App component.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.228.35