Skip to content

Module quiz: React Hooks and Custom Hooks :Advanced React (Meta Front-End Developer Professional Certificate) Answers 2025

 

1. How is array destructuring relevant to hooks?

✔️ It is a way to get individual items from an array of items (React hooks return arrays)
❌ Makes it possible to reassign state
❌ Makes Virtual DOM possible
❌ Handles click events


2. Is the paragraph about destructuring correct?

✔️ Yes
(You can rename array items freely. Object destructuring requires using property names unless using alias syntax like const {name: myName}.)


3. useEffect hook is used to:

❌ handle one-way data flows
✔️ handle side effects
❌ handle animations


4. Code snippet validity

The snippet:

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

✔️ This code is NOT breaking the rules of hooks
❌ Replace if with ternary
❌ Breaking rules

(The issue is missing dependency array → causes infinite loop, but that is not a rules-of-hooks violation.)


5. Example of a side effect

❌ Render prop values
✔️ Run a Fetch API call
❌ Update state in child


6. Complete the sentence

✔️ The useReducer hook gets a reducer function in addition to initial state
❌ Cannot track state
❌ Must be used when initial state is object


7. useRef is a custom hook

❌ True
✔️ False
(useRef is a built-in React hook, not a custom one.)


8. JS is single-threaded meaning…

✔️ It can only do one thing at a time
❌ Requires useEffect to work
❌ Requires passing to state


9. Code snippet meaning

✔️ This is an example of a custom hook
❌ Implicit state update
❌ Explicit state update


10. Error in the code

function updateRestaurantName() {
useRestaurantName("Little Lemon");
}

✔️ The error is: you should not call useRestaurantName() — hooks must NOT be called inside functions
❌ onClick incorrect
❌ setRestaurantName wrong name


📘 Summary Table

Q Correct Answer
1 First option
2 Yes
3 Side effect
4 Not breaking rules
5 Fetch API
6 useReducer gets reducer function
7 False
8 Can do only one thing at a time
9 Custom hook
10 Should not call useRestaurantName inside function