# Knowledge check: Table booking system

1. **What is the purpose of the** `useState` **hook in React?**
    
    * To bind an event handler to an element.
        
    * To bind a value to the props of a component.
        
    * <mark>To manage the component's state</mark>
        
    * To manage the component's context
        
2. **What is missing from the code below?**
    
    ```javascript
    import { useState } from "react";
    
    export default function App() {
      const [restaurantName, setRestaurantName] = useState();
      return <h1>{restaurantName}</h1>;
    }
    ```
    
    * The `setRestaurantName` function.
        
    * The `useState` hook import statement
        
    * `useReducer` hook was not used
        
    * <mark>An initial value for the state variable </mark> `restaurantName`
        
3. **Controlled components keep their internal state in the DOM**
    
    * True
        
    * <mark>False</mark>
        
4. **What is unit testing in React?**
    
    * <mark>A type of testing that ensures that individual units of code are working as intended.</mark>
        
    * A type of testing that ensures that a complete application is working as intended.
        
    * A type of testing that involves manually testing a component's UI.
        
    * A type of testing that ensures that a component's props and state are correctly being passed down to its children.
        
5. **What is the main difference between the** `useState` **and** `useReducer` **hooks in React?**
    
    * `useState` is used for managing component state, while `useReducer` is used for managing the component lifecycle.
        
    * `useState` is used for managing component state, while `useReducer` is used for managing the component's UI.
        
    * `useState` is used for managing component state, while `useReducer` is used for managing global state.
        
    * `useState` <mark> is used for simple state updates, while </mark> `useReducer` <mark> is used for complex state updates.</mark>
        

---

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728115131102/9b49f2a9-962c-4d70-8047-50aeac4017ba.png align="center")
