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

(autofix) Fix feedback button bugs #1410

Open
ram-senth opened this issue Nov 8, 2024 · 0 comments
Open

(autofix) Fix feedback button bugs #1410

ram-senth opened this issue Nov 8, 2024 · 0 comments
Assignees

Comments

@ram-senth
Copy link
Member

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

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

No branches or pull requests

2 participants