qortex-react 0.1.3 → 0.1.4
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/README.md +15 -10
- package/index.d.ts +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/qortex-react)
|
|
6
6
|
[](https://bundlephobia.com/package/qortex-react)
|
|
7
|
+
[](https://bundlephobia.com/package/qortex-react)
|
|
7
8
|
[](https://www.typescriptlang.org/)
|
|
8
9
|
[](https://reactjs.org/)
|
|
9
10
|
|
|
@@ -125,6 +126,8 @@ const {
|
|
|
125
126
|
data,
|
|
126
127
|
isLoading,
|
|
127
128
|
isFetching,
|
|
129
|
+
isSuccess,
|
|
130
|
+
isError,
|
|
128
131
|
error,
|
|
129
132
|
refetch,
|
|
130
133
|
status,
|
|
@@ -281,18 +284,20 @@ queryManager.registerFetcher<User[]>(["users"], {
|
|
|
281
284
|
});
|
|
282
285
|
|
|
283
286
|
function UsersList() {
|
|
284
|
-
const { data: users, isLoading, error } = useQuery<User[]>(["users"]);
|
|
287
|
+
const { data: users, isLoading, isSuccess, isError, error } = useQuery<User[]>(["users"]);
|
|
285
288
|
|
|
286
289
|
if (isLoading) return <div>Loading...</div>;
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
if (isError) return <div>Error: {error?.message}</div>;
|
|
291
|
+
if (isSuccess && users) {
|
|
292
|
+
return (
|
|
293
|
+
<ul>
|
|
294
|
+
{users.map(user => (
|
|
295
|
+
<li key={user.id}>{user.name} - {user.email}</li>
|
|
296
|
+
))}
|
|
297
|
+
</ul>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
return <div>No users found</div>;
|
|
296
301
|
}
|
|
297
302
|
|
|
298
303
|
// Or use useQueryData for simpler typed access
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fetcher, QueryKey, QueryOptions,
|
|
1
|
+
import { Fetcher, QueryKey, QueryOptions, InferFetcherResult, QueryState } from 'qortex-core';
|
|
2
2
|
export * from 'qortex-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,9 +6,9 @@ export * from 'qortex-core';
|
|
|
6
6
|
* Provides reactive data fetching with automatic re-renders on state changes
|
|
7
7
|
* Enhanced with automatic type inference from fetchers
|
|
8
8
|
*/
|
|
9
|
-
declare function useQuery<F extends Fetcher>(key: QueryKey, opts: QueryOptions<
|
|
9
|
+
declare function useQuery<F extends Fetcher>(key: QueryKey, opts: QueryOptions<InferFetcherResult<F>> & {
|
|
10
10
|
fetcher: F;
|
|
11
|
-
}): QueryState<
|
|
11
|
+
}): QueryState<InferFetcherResult<F>>;
|
|
12
12
|
declare function useQuery<T = any>(key: QueryKey, opts?: QueryOptions<T>): QueryState<T>;
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -16,9 +16,9 @@ declare function useQuery<T = any>(key: QueryKey, opts?: QueryOptions<T>): Query
|
|
|
16
16
|
* Provides reactive data fetching with automatic re-renders on state changes
|
|
17
17
|
* Enhanced with automatic type inference from fetchers
|
|
18
18
|
*/
|
|
19
|
-
declare function useQueryData<F extends Fetcher>(key: QueryKey, opts: QueryOptions<
|
|
19
|
+
declare function useQueryData<F extends Fetcher>(key: QueryKey, opts: QueryOptions<InferFetcherResult<F>> & {
|
|
20
20
|
fetcher: F;
|
|
21
|
-
}):
|
|
21
|
+
}): InferFetcherResult<F> | undefined;
|
|
22
22
|
declare function useQueryData<T = any>(key: QueryKey, opts?: QueryOptions<T>): T | undefined;
|
|
23
23
|
|
|
24
24
|
export { useQuery, useQueryData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qortex-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "React hook bridge for qortex runtime",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"author": "Darshan Naik",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"qortex-core": "0.1.
|
|
45
|
+
"qortex-core": "0.1.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18"
|