Complete the code to import the useCallback hook from React.
import React, { [1] } from 'react';
The useCallback hook is imported from React to memoize functions.
Complete the code to memoize the handleClick function using useCallback with an empty dependency array.
const handleClick = [1](() => { console.log('Clicked'); }, []);
useCallback memoizes the function so it doesn't get recreated on every render.
Fix the error in the useCallback dependency array to include the correct dependency.
const increment = useCallback(() => {
setCount(count + 1);
}, [[1]]);The count variable is used inside the callback, so it must be in the dependency array.
Fill both blanks to create a memoized function that depends on 'value' and logs it.
const logValue = useCallback(() => {
console.log([1]);
}, [[2]]);The function logs value and depends on value to update correctly.
Fill both blanks to create a memoized function that adds 'a' and 'b' and depends on both.
const add = useCallback(() => {
return [1] + [2];
}, [[1], [2]]);The function adds a and b, returns their sum, and depends on both.