Using component function names in query keys?
We're noticing that text-based query keys are easy to overlook or lead to human error since we can't lint them. Because our components are very clearly named like
LogReadingsMainGrid I was thinking maybe we can use the function name.
So instead of typing useQuery(['logReadingsMainGrid', id], ... we can use useQuery([LogReadingsMainGrid.name, id], ... where LogReadingsMainGrid is the component function name.
In my tests this works fine and linters can catch if a developer copies this code into a new component and forgets to change it. However I'm wondering there's a reason not to do this that I'm not seeing.0 Replies