How to avoid expensive re-calculations
React has a built-in hook called useMemo that allows you to memoize expensive functions so that you can avoid calling them on every render.
const allItems = getItems(inputValue)const allItems = React.useMemo(() => getItems(inputValue), [inputValue])Last updated