Skip to content

Conversation

@oshi97
Copy link
Contributor

@oshi97 oshi97 commented Apr 14, 2022

This commit updates DropdownItem itemData usages to be wrapped inside a useMemo.
Originally, I tried refactoring Dropdown to not use itemData, since itemData feels
a bit like an anti pattern, however this proved to be very difficult.

I also tried wrapping DropdownItem usages inside a parent component, like
FilterSearchDropdownItem, however recursivelyMapChildren does not work
for wrapper components that internally use DropdownItem. It only works
when DropdownItem is specified as a direct child.

So, as a workaround, I wrapped itemData usages inside useMemo by creating
a 2d matrix of item datas, itemDataMatrix, which is then referenced by component
usages.

J=SLAP-2016
TEST=manual

see that autocomplete options appear and can be selected
see that filtersearch results appear and can be selected and applied to the search
resolved all eslint warnings. yay!

oshi97 added 2 commits April 14, 2022 12:23
This commit updates DropdownItem itemData usages to be wrapped inside a useMemo.
Originally, I tried refactoring Dropdown to not use itemData, since itemData feels
a bit like an anti pattern, however this proved to be very difficult.

I also tried wrapping DropdownItem usages inside a parent component, like
FilterSearchDropdownItem, however recursivelyMapChildren does not work
for wrapper components that internally use DropdownItem. It only works
when DropdownItem is specified as a direct child.

So, as a workaround, I wrapped itemData usages inside useMemo by creating
a 2d matrix of item datas, itemDataMatrix, which is then referenced by component
usages.

J=SLAP-2016
TEST=manual

see that autocomplete options appear and can be selected
see that filtersearch results appear and can be selected and applied to the search
@oshi97 oshi97 requested a review from a team as a code owner April 14, 2022 16:31
@oshi97 oshi97 merged commit 897e720 into main Apr 14, 2022
@oshi97 oshi97 deleted the dev/refactor-item-data branch April 14, 2022 18:12
yen-tt pushed a commit that referenced this pull request Sep 28, 2022
This commit updates DropdownItem itemData usages to be wrapped inside a useMemo.
Originally, I tried refactoring Dropdown to not use itemData, since itemData feels
a bit like an anti pattern, however this proved to be very difficult.

I also tried wrapping DropdownItem usages inside a parent component, like
FilterSearchDropdownItem, however recursivelyMapChildren does not work
for wrapper components that internally use DropdownItem. It only works
when DropdownItem is specified as a direct child.

So, as a workaround, I wrapped itemData usages inside useMemo by creating
a 2d matrix of item datas, itemDataMatrix, which is then referenced by component
usages.

J=SLAP-2016
TEST=manual

see that autocomplete options appear and can be selected
see that filtersearch results appear and can be selected and applied to the search
resolved all eslint warnings. yay!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants