Why is my form keeping old values after mutation?
https://github.com/Makistos/suomisf-ui/blob/debug/src/features/work/components/work-form.tsx
For some reason I need to open this form twice to show the changes I made in earlier edit. I.e. I open it, make some changes, close form and reopen -> it has the old values. I close & open once more -> now its updated. Why? I have three query keys in the page this form is part of, all have two common parts: "work" and <id> and I invalidate queries with those two parts. Main page updates when I close the form properly but the other two don't.
I thought it was because main page's query is disabled while form is open but I tried to disable form's query as well when mutating and then enabling after but that did not help.
GitHub
suomisf-ui/src/features/work/components/work-form.tsx at debug · Ma...
React UI for Suomisf website. Backend is in the suomisf repository. - Makistos/suomisf-ui
2 Replies
rival-black•17mo ago
Google tkdodo forms query
harsh-harlequinOP•17mo ago
I have read it several times.
Have "Mastering mutations" page open as we speak.
But there is clearly something I don't get. What forces a reload of data immediately?
I tried reset() as well but it does nothing.
Ookay, now it might work, required both reset and invalidateQuery.