How is array destructuring relevant to hooks in React?
It makes it possible to reassign state objects.
It makes the Virtual DOM possible.
It makes it possible to handle click events.
It is a way to get individual items from an array of items, and save those individual items as separate components.
Is the following paragraph correct?
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.
Yes
No
The
useEffecthook is a way to:handle visual effects (animations and transitions) in React
handle one-way data flows
handle a side effect.
Which answer is correct about the following code snippet?
useEffect( () => { if (data !== '') { setData('test data') } })This code is breaking the rules of hooks
This code is not breaking the rules of hooks
This code is ok, except the fact that you should replace the if statement with a ternary operator.
Choose an example of a side-effect with which you’d need to use a useEffect hook:
Run a Fetch API call in React.
Update the value of the state variable in a child component.
Render some prop values on the screen.
Complete the sentence:
The
useStatehook starts with an initial state, but...the
useReducerhook cannot be used to track the state at all.the
useReducerhook gets a reducer function in addition to the initial state.the
userReducerhook must be used when the initial state is an object.
True or false:
useRefis a custom hook in React.Yes.
No
JavaScript is a single-threaded language, meaning...
...you can use it with React only when this single thread is used with the
useEffecthook....it can only do a single thing at any given time.
...you can use it with React only when this single thread is passed to the
useStatevariable.
Which statement is correct about the following code snippet:
import { useEffect } from "react"; function useConsoleLog(varName) { useEffect(() => { console.log(varName); }); } export default useConsoleLog;Choose the correct statement below.
This is an example of a custom hook.
This code is an example of an implicit state-updating function.
This code is an example of an explicit state-updating function.
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> ); };The
onClickevent should not be this:onClick={updateRestaurantName}The code inside the
updateRestaurantName()function definition should not invokeuseRestaurantName("Little Lemon")The state-setting function's variable name in the array destructuring should not be
setRestaurantName.





