-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(dashboards): rely on useQueries for referential stability of data #107340
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
base: master
Are you sure you want to change the base?
ref(dashboards): rely on useQueries for referential stability of data #107340
Conversation
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
static/app/views/dashboards/widgetCard/hooks/useMobileAppSizeWidgetQuery.tsx
Outdated
Show resolved
Hide resolved
| firstError: results.find(q => q?.error)?.error as any, | ||
| queryData: results.map(q => q.data), | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate combine functions with only type cast difference
Low Severity
Two nearly-identical functions combineQueryResultsWithFullError and combineQueryResultsWithRequestError have the same logic, differing only in the type cast on firstError (as any vs as RequestError | undefined). These could be consolidated into a single shared utility function that returns firstError: results.find(q => q?.error)?.error and let callers handle typing, reducing duplication and maintenance burden.
Additional Locations (1)
…ueries-reference-stability-in-order-instead-of


Previously in the dashboard api hooks we would store query result data in a ref, on rerender of the hook we would compare against that ref to see if data has changed. This works but there's a better way with react query.
Instead we use the combine property of
useQueriesto maintain ref stability which is less manual and less error prone