@spoosh/react 0.1.1 → 0.1.2

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/dist/index.js CHANGED
@@ -101,7 +101,11 @@ function createUseRead(options) {
101
101
  controller.getState,
102
102
  controller.getState
103
103
  );
104
- const [requestState, setRequestState] = (0, import_react.useState)({ isPending: false, error: void 0 });
104
+ const [requestState, setRequestState] = (0, import_react.useState)(() => {
105
+ const cachedEntry = stateManager.getCache(queryKey);
106
+ const hasCachedData = cachedEntry?.state?.data !== void 0;
107
+ return { isPending: enabled && !hasCachedData, error: void 0 };
108
+ });
105
109
  const abortRef = (0, import_react.useRef)(controller.abort);
106
110
  abortRef.current = controller.abort;
107
111
  const pluginOptsKey = JSON.stringify(pluginOpts);
package/dist/index.mjs CHANGED
@@ -85,7 +85,11 @@ function createUseRead(options) {
85
85
  controller.getState,
86
86
  controller.getState
87
87
  );
88
- const [requestState, setRequestState] = useState({ isPending: false, error: void 0 });
88
+ const [requestState, setRequestState] = useState(() => {
89
+ const cachedEntry = stateManager.getCache(queryKey);
90
+ const hasCachedData = cachedEntry?.state?.data !== void 0;
91
+ return { isPending: enabled && !hasCachedData, error: void 0 };
92
+ });
89
93
  const abortRef = useRef(controller.abort);
90
94
  abortRef.current = controller.abort;
91
95
  const pluginOptsKey = JSON.stringify(pluginOpts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "description": "React hooks for Spoosh API client",
6
6
  "keywords": [
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@spoosh/core": "0.2.0"
37
+ "@spoosh/core": "0.2.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18 || ^19"