Created
October 19, 2022 19:17
-
-
Save Willienn/88204c14de50d95bd133626247652982 to your computer and use it in GitHub Desktop.
Useful things
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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