Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap DropdownItem itemData usages with useMemo #114

Merged
merged 4 commits into from
Apr 14, 2022
Merged

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!

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
src/components/FilterSearch.tsx Outdated Show resolved Hide resolved
src/components/FilterSearch.tsx Outdated Show resolved Hide resolved
@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.

2 participants