@hyper-fetch/react 9.6.0 → 9.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/react",
3
- "version": "9.6.0",
3
+ "version": "9.6.1",
4
4
  "description": "React hooks and utils for the hyper-fetch",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",
@@ -169,10 +169,12 @@ export const useRequestEvents = <R extends RequestInstance>({
169
169
 
170
170
  if (data instanceof Promise) {
171
171
  return (async () => {
172
- handleResponseCallbacks({
173
- ...values,
174
- response: (await data) as ResponseType<any, any, ExtractAdapterType<R>>,
175
- });
172
+ const response = (await data) as ResponseType<any, any, ExtractAdapterType<R>>;
173
+ // The mapper can outlive the component - the unmount cleanup can't stop a response already being mapped
174
+ if (!isMounted.current) {
175
+ return;
176
+ }
177
+ handleResponseCallbacks({ ...values, response });
176
178
  })();
177
179
  }
178
180
  return handleResponseCallbacks(values);