Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

The best abstraction

0 views
Skip to first unread message

Mike Austin

unread,
Feb 8, 2025, 8:55:07 PMFeb 8
to PiLuD
For quite a while I had a transformItems() conversion function that I used in a few places. Why am I doing it at different call sites instead of transforming the data at the source?

Original:

const { data } = useQuery({
  query: "SELECT_ITEMS",
  variables: {
    params.teamKey
  }
})

const items = transformItems(selectItemsData.items);

Refactored:

const items = useSelectItemsQuery(teamKey: string);

Now that I think of it, I did this years ago at work for a different project. Sometimes the mind just slips while thinking of too many things at once.
Reply all
Reply to author
Forward
0 new messages