You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gotta be careful to only update the prev value only if the new value is changed…. so maybe usePrevious isn’t what we want, something like useRef might be enough, or useState if all else fails
const autofixData = isReset ? null : apiData?.autofix ?? null;
could also try to push the fetch call down into the drawer a little lower, so things like the feedback button and those chevrons are in a parent component, and the data is fetched in a child component
The text was updated successfully, but these errors were encountered:
the whole drawer is rerendering when we poll for the Autofix state, causing the feedback button to remount
Suggestion from Ryan Albrecht:
I think what I would do is add usePrevious to that useAiAutofix() hook, to keep track of the prev data
and then near this line: https://github.com/getsentry/sentry/blob/20cf72013990dec04482d97ea969b849fb763169/static/app/components/events/autofix/useAutofix.tsx#L130 I would check if the updated_at is the same (and maybe also check the run_id and/or last_triggered_at ) if things are the same then we want to re-use the previous value.
gotta be careful to only update the prev value only if the new value is changed…. so maybe usePrevious isn’t what we want, something like useRef might be enough, or useState if all else fails
const autofixData = isReset ? null : apiData?.autofix ?? null;
you can also try to read about structuralSharing in the docs https://tanstack.com/query/v5/docs/framework/react/reference/useQuery and use that to do the same kind of logic.
what’s happening is each time the response comes back we have a ‘new’ object reference, so react is re-rendering everything
https://tanstack.com/query/v5/docs/framework/react/reference/useQuery
could also try to push the fetch call down into the drawer a little lower, so things like the feedback button and those chevrons are in a parent component, and the data is fetched in a child component
The text was updated successfully, but these errors were encountered: