@sylphx/lens-react 2.3.3 → 2.3.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/dist/index.js CHANGED
@@ -21,12 +21,14 @@ function queryReducer(state, action) {
21
21
  }
22
22
  function createUseQueryHook(getEndpoint) {
23
23
  return function useQuery(options) {
24
+ const inputKey = JSON.stringify(options?.input);
25
+ const selectKey = JSON.stringify(options?.select);
24
26
  const query = useMemo(() => {
25
27
  if (options?.skip)
26
28
  return null;
27
29
  const endpoint = getEndpoint();
28
30
  return endpoint({ input: options?.input, select: options?.select });
29
- }, [options?.input, options?.select, options?.skip, getEndpoint]);
31
+ }, [inputKey, selectKey, options?.skip]);
30
32
  const initialState = {
31
33
  data: null,
32
34
  loading: query != null && !options?.skip,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/lens-react",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "React bindings for Lens API framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/create.tsx CHANGED
@@ -165,12 +165,18 @@ function createUseQueryHook<TInput, TOutput>(
165
165
  getEndpoint: () => (options: unknown) => QueryResult<TOutput>,
166
166
  ) {
167
167
  return function useQuery(options?: QueryHookOptions<TInput>): QueryHookResult<TOutput> {
168
+ // Use JSON.stringify for stable dependency comparison
169
+ // This prevents re-fetching when input object reference changes but content is the same
170
+ const inputKey = JSON.stringify(options?.input);
171
+ const selectKey = JSON.stringify(options?.select);
172
+
168
173
  // Get query result from base client
174
+ // biome-ignore lint/correctness/useExhaustiveDependencies: Using JSON.stringify keys (inputKey, selectKey) for stable comparison instead of object references
169
175
  const query = useMemo(() => {
170
176
  if (options?.skip) return null;
171
177
  const endpoint = getEndpoint();
172
178
  return endpoint({ input: options?.input, select: options?.select });
173
- }, [options?.input, options?.select, options?.skip, getEndpoint]);
179
+ }, [inputKey, selectKey, options?.skip]);
174
180
 
175
181
  // State management
176
182
  const initialState: QueryState<TOutput> = {