Summary
useMutation in packages/data/src/hooks/useMutation.ts does not track request order. If mutate() is called twice and the first request resolves after the second, the older response can overwrite the newer data state.
Reproduction
- Create a component using useMutation('/save', 'POST').
- Call mutate({ value: 'old' }), then quickly call mutate({ value: 'new' }).
- Make the
ew request resolve first and the old request resolve last.
Expected behavior
The hook should either document that concurrent mutations are unsupported or guard state updates so the latest mutation result remains visible.
Actual behavior
The older response can call setData(result) after the newer response and leave the UI showing stale mutation data.
Summary
useMutation in packages/data/src/hooks/useMutation.ts does not track request order. If mutate() is called twice and the first request resolves after the second, the older response can overwrite the newer data state.
Reproduction
ew request resolve first and the old request resolve last.
Expected behavior
The hook should either document that concurrent mutations are unsupported or guard state updates so the latest mutation result remains visible.
Actual behavior
The older response can call setData(result) after the newer response and leave the UI showing stale mutation data.