Skip to content

Instantly share code, notes, and snippets.

@Willienn
Created October 19, 2022 19:17
Show Gist options
  • Select an option

  • Save Willienn/88204c14de50d95bd133626247652982 to your computer and use it in GitHub Desktop.

Select an option

Save Willienn/88204c14de50d95bd133626247652982 to your computer and use it in GitHub Desktop.
Useful things
const Something = useMemo(() => {
const dictionary = {};
currentItems.forEach((item) => {
const categoryName = item.categoryName;
if (dictionary[categoryName]) {
// push item in a list
dictionary[categoryName].push(item);
} else {
// create a list with an item;
dictionary[categoryName] = [item];
}
});
return dictionary;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment