1. How is array destructuring relevant to hooks in React?

    <aside>

    it is a way to get individual items from an array of items and save them as separate components

    </aside>

  2. With array destructuring, you are free to give any variable name to the items that you destructure from an array. Contrary to that, when destructuring objects, you have to destructure a property of an object using that exact property's name as the name of the destructured variable.

    <aside>

    this is true

  3. The useEffect hook is a way to

    <aside>

    handle a side effect

    </aside>

  4. Which answer is correct about the following code snippet?

    useEffect( () => {
      if (data !== '') {
        setData('test data')
      }
    })
    

    <aside>

    the code is not breaking the rules of hooks

    </aside>

  5. Choose an example of a side effect with which you’d need to use a useEffect hook:

    <aside>

    run a Fetch API call in React

    </aside>

  6. The useState hook starts with an initial state, but...

    <aside>

    the useReducer hook gets a reducer function in addition to the initial state

    </aside>

  7. useRef is…

    <aside>

    a built-in hook in React

    </aside>

  8. JavaScript is a single-threaded language, meaning…

    <aside>

    it can only do a single thing at any given time

    </aside>

  9. Which statement is correct about the following code snippet:

    import { useEffect } from "react";
    
    function useConsoleLog(varName) {
      useEffect(() => {
        console.log(varName);
      });
    }
    
    export default useConsoleLog;
    

    <aside>

    this is an example of a custom hook

    </aside>

  10. Find the error in this code:

    import {useState} from "react";
    
    export default function App() {
      const [restaurantName, setRestaurantName] = useState("Lemon");
    
      function updateRestaurantName() {
        useRestaurantName("Little Lemon");
      };
    
      return (
        <div>
          <h1>{restaurantName}</h1>
          <button onClick={updateRestaurantName}>
            Update restaurant name
          </button>
        </div>
      );
    };
    

    <aside>

    the code inside updateRestaurantName() should not invoke useRestaurantName(), it should invoke setRestaurantName()

    </aside>