@umituz/react-native-ai-generation-content 1.83.37 → 1.83.38

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": "@umituz/react-native-ai-generation-content",
3
- "version": "1.83.37",
3
+ "version": "1.83.38",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -30,6 +30,15 @@ export const useGenerationOrchestrator = <TInput, TResult>(
30
30
  const abortControllerRef = useRef<AbortController | null>(null);
31
31
  const cleanupTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
32
32
 
33
+ // Stable refs for callbacks — prevents useCallback deps from thrashing when
34
+ // callers pass inline functions (which create new references every render).
35
+ const onSuccessRef = useRef(onSuccess);
36
+ const onErrorRef = useRef(onError);
37
+ useEffect(() => {
38
+ onSuccessRef.current = onSuccess;
39
+ onErrorRef.current = onError;
40
+ });
41
+
33
42
  const offlineStore = useOfflineStore();
34
43
  const { showError, showSuccess } = useAlert();
35
44
 
@@ -109,11 +118,11 @@ export const useGenerationOrchestrator = <TInput, TResult>(
109
118
  }
110
119
 
111
120
  if (alertMessages.success) showSuccess("Success", alertMessages.success);
112
- await onSuccess?.(result);
121
+ await onSuccessRef.current?.(result);
113
122
  handleLifecycleComplete("success", result);
114
123
  return result;
115
124
  },
116
- [strategy, userId, alertMessages, showSuccess, onSuccess, handleLifecycleComplete],
125
+ [strategy, userId, alertMessages, showSuccess, handleLifecycleComplete],
117
126
  );
118
127
 
119
128
  const generate = useCallback(
@@ -201,7 +210,7 @@ export const useGenerationOrchestrator = <TInput, TResult>(
201
210
  if (typeof __DEV__ !== "undefined" && __DEV__) console.log("[Orchestrator] Error:", error);
202
211
  if (isMountedRef.current) setState({ status: "error", isGenerating: false, result: null, error });
203
212
  showError("Error", getAlertMessage(error, alertMessages));
204
- await onError?.(error);
213
+ await onErrorRef.current?.(error);
205
214
  handleLifecycleComplete("error", undefined, error);
206
215
  throw error;
207
216
  } finally {
@@ -212,7 +221,7 @@ export const useGenerationOrchestrator = <TInput, TResult>(
212
221
  abortControllerRef.current = null;
213
222
  }
214
223
  },
215
- [offlineStore, moderation, alertMessages, strategy, executeGeneration, showError, onError, handleLifecycleComplete],
224
+ [offlineStore, moderation, alertMessages, strategy, executeGeneration, showError, handleLifecycleComplete],
216
225
  );
217
226
 
218
227
  const reset = useCallback(() => {