Complete the code to import the useMemo hook from React.
import React, { [1] } from 'react';
The useMemo hook is imported from React to memoize expensive calculations.
Complete the code to memoize the result of the expensiveFunction using useMemo.
const memoizedValue = useMemo(() => expensiveFunction(), [1]);Passing an empty array [] means the function runs only once on mount.
Fix the error in the useMemo usage to correctly memoize based on 'count'.
const memoizedValue = useMemo(() => computeValue(count), [1]);The dependency array must be an array containing count to update memoizedValue when count changes.
Fill both blanks to memoize the sum of a and b, updating only when a or b changes.
const sum = useMemo(() => [1] + [2], [a, b]);
The sum is calculated by adding a and b inside useMemo.
Fill all three blanks to create a memoized object with keys 'x', 'y', and 'z' from props.
const memoizedObj = useMemo(() => ({ x: [1], y: [2], z: [3] }), [props.x, props.y, props.z]);The object keys get their values from props.x, props.y, and props.z respectively.