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>
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
name) to extract the value
</aside>The useEffect hook is a way to
<aside>
handle a side effect
</aside>
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>
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>
The useState hook starts with an initial state, but...
<aside>
the useReducer hook gets a reducer function in addition to the initial state
</aside>
useRef is…
<aside>
a built-in hook in React
</aside>
JavaScript is a single-threaded language, meaning…
<aside>
it can only do a single thing at any given time
</aside>
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>
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>