Because of HMR, some modules would be re-executed and singletons would be recreated. Typically, the whole router in vase a ViewXXX component would be updated, and the queryClient for react-query.
Weirdly, the invalidate() function would not work anymore (I tried a loooot of things).
This PR moves the routes data invalidation closer to the actual mutation, and move it out of the APIs. It's less clean and easier to miss when adding new code, but at the same time a bit more "correct" and it fixes the HMR issues.
If anyone has a better solution for this problem, feel free to share.
Because of HMR, some modules would be re-executed and singletons would be recreated. Typically, the whole router in vase a
ViewXXX
component would be updated, and thequeryClient
forreact-query
.Weirdly, the
invalidate()
function would not work anymore (I tried a loooot of things).This PR moves the routes data invalidation closer to the actual mutation, and move it out of the APIs. It's less clean and easier to miss when adding new code, but at the same time a bit more "correct" and it fixes the HMR issues.
If anyone has a better solution for this problem, feel free to share.