Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created April 12, 2023 00:06
Show Gist options
  • Select an option

  • Save solanoize/95aa3250674b991f04522c0e29a352db to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/95aa3250674b991f04522c0e29a352db to your computer and use it in GitHub Desktop.
const computedTotal = useMemo(() => {
let sum = 0;
if (itemSales.length > 0) {
for (let item of itemSales) {
sum += item.price * item.qty;
}
}
setSale((values) => ({ ...values, total: sum }));
return null;
}, [itemSales]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment