@umituz/react-native-bottom-sheet 1.2.4 → 1.2.6

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-bottom-sheet",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Modern, performant bottom sheets for React Native with preset configurations, keyboard handling, and smooth animations",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -30,7 +30,6 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@gorhom/bottom-sheet": ">=5.0.0",
33
- "@umituz/react-native-animation": "*",
34
33
  "@umituz/react-native-design-system": "*",
35
34
  "@umituz/react-native-design-system-theme": "*",
36
35
  "react": ">=18.2.0",
@@ -43,7 +42,6 @@
43
42
  "@react-native-async-storage/async-storage": "^2.2.0",
44
43
  "@types/react": "^18.2.45",
45
44
  "@types/react-native": "^0.73.0",
46
- "@umituz/react-native-animation": "latest",
47
45
  "@umituz/react-native-design-system": "latest",
48
46
  "@umituz/react-native-design-system-theme": "latest",
49
47
  "react": "^18.2.0",
@@ -37,7 +37,6 @@ import GorhomBottomSheet, {
37
37
  type BottomSheetBackdropProps,
38
38
  } from '@gorhom/bottom-sheet';
39
39
  import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
40
- import { useReanimatedReady } from '@umituz/react-native-animation';
41
40
  import type {
42
41
  BottomSheetConfig,
43
42
  BottomSheetPreset,
@@ -155,14 +154,6 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
155
154
  ) => {
156
155
  const tokens = useAppDesignTokens();
157
156
  const sheetRef = React.useRef<GorhomBottomSheet>(null);
158
- // CRITICAL: Use centralized Reanimated ready check from animation package
159
- // This must be true before GorhomBottomSheet is rendered
160
- // Otherwise, internal hooks (useAnimatedLayout) will access containerLayoutState.get
161
- // before Reanimated is ready, causing "containerLayoutState.get is not a function" errors
162
- //
163
- // MINIMAL FIX: Don't render GorhomBottomSheet at all until Reanimated is ready
164
- // This prevents internal hooks from running before Reanimated is initialized
165
- const isReanimatedReady = useReanimatedReady();
166
157
 
167
158
  // Get configuration from preset or custom (must be before useImperativeHandle)
168
159
  const config: BottomSheetConfig = useMemo(() => {
@@ -219,49 +210,26 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
219
210
  [onChange, onClose]
220
211
  );
221
212
 
222
- // Expose ref methods (must be before early return to maintain hook order)
213
+ // Expose ref methods
223
214
  React.useImperativeHandle(ref, () => ({
224
215
  snapToIndex: (index: number) => {
225
- if (isReanimatedReady && sheetRef.current) {
226
- sheetRef.current.snapToIndex(index);
227
- }
216
+ sheetRef.current?.snapToIndex(index);
228
217
  },
229
218
  snapToPosition: (position: string | number) => {
230
- if (isReanimatedReady && sheetRef.current) {
231
- sheetRef.current.snapToPosition(position);
232
- }
219
+ sheetRef.current?.snapToPosition(position);
233
220
  },
234
221
  expand: () => {
235
- if (isReanimatedReady && sheetRef.current) {
236
- sheetRef.current.expand();
237
- }
222
+ sheetRef.current?.expand();
238
223
  },
239
224
  collapse: () => {
240
- if (isReanimatedReady && sheetRef.current) {
241
- sheetRef.current.collapse();
242
- }
225
+ sheetRef.current?.collapse();
243
226
  },
244
227
  close: () => {
245
- if (isReanimatedReady && sheetRef.current) {
246
- sheetRef.current.close();
247
- }
228
+ sheetRef.current?.close();
248
229
  },
249
- }));
250
-
251
- // MINIMAL FIX: Don't render GorhomBottomSheet at all until Reanimated is fully ready
252
- // This is the root cause fix - if we don't render GorhomBottomSheet, its internal hooks
253
- // (useAnimatedLayout, useAnimatedDetents, etc.) won't run, preventing the error
254
- //
255
- // GorhomBottomSheet's internal hooks access Reanimated's containerLayoutState.get during initialization
256
- // If we render before Reanimated is ready, we get "containerLayoutState.get is not a function" errors
257
- //
258
- // IMPORTANT: All hooks must be called before this early return to maintain hook order
259
- if (!isReanimatedReady) {
260
- return null;
261
- }
230
+ }), []);
262
231
 
263
- // Double-check: Ensure we have a valid config before rendering
264
- // This prevents errors if snapPoints are invalid
232
+ // Ensure valid config
265
233
  if (!config.snapPoints || config.snapPoints.length === 0) {
266
234
  return null;
267
235
  }
@@ -39,7 +39,6 @@ import {
39
39
  type BottomSheetBackdropProps,
40
40
  } from '@gorhom/bottom-sheet';
41
41
  import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
42
- import { useReanimatedReady } from '@umituz/react-native-animation';
43
42
  import type {
44
43
  BottomSheetConfig,
45
44
  BottomSheetPreset,
@@ -157,8 +156,6 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
157
156
  ) => {
158
157
  const tokens = useAppDesignTokens();
159
158
  const modalRef = React.useRef<GorhomBottomSheetModal>(null);
160
- // Use centralized Reanimated ready check from animation package
161
- const isMounted = useReanimatedReady();
162
159
 
163
160
  // Get configuration from preset or custom (must be before useImperativeHandle)
164
161
  const config: BottomSheetConfig = useMemo(() => {
@@ -215,49 +212,27 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
215
212
  [onChange, onDismiss]
216
213
  );
217
214
 
218
- // Expose ref methods (must be before early return to maintain hook order)
215
+ // Expose ref methods
219
216
  React.useImperativeHandle(ref, () => ({
220
217
  present: () => {
221
- // @gorhom/bottom-sheet's present() automatically opens from bottom to first snap point
222
- // useReanimatedReady() ensures GorhomBottomSheetModal is only rendered when Reanimated is ready
223
- // So we can safely call present() without additional delays
224
- if (isMounted && modalRef.current) {
225
- modalRef.current.present();
226
- }
218
+ modalRef.current?.present();
227
219
  },
228
220
  dismiss: () => {
229
- if (isMounted) {
230
221
  modalRef.current?.dismiss();
231
- }
232
222
  },
233
223
  snapToIndex: (index: number) => {
234
- if (isMounted) {
235
224
  modalRef.current?.snapToIndex(index);
236
- }
237
225
  },
238
226
  snapToPosition: (position: string | number) => {
239
- if (isMounted) {
240
227
  modalRef.current?.snapToPosition(position);
241
- }
242
228
  },
243
229
  expand: () => {
244
- if (isMounted) {
245
230
  modalRef.current?.expand();
246
- }
247
231
  },
248
232
  collapse: () => {
249
- if (isMounted) {
250
233
  modalRef.current?.collapse();
251
- }
252
234
  },
253
- }));
254
-
255
- // Don't render until mounted to prevent early hook execution
256
- // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
257
- // IMPORTANT: All hooks must be called before this early return to maintain hook order
258
- if (!isMounted) {
259
- return null;
260
- }
235
+ }), []);
261
236
 
262
237
  return (
263
238
  <GorhomBottomSheetModal
@@ -18,7 +18,6 @@
18
18
 
19
19
  import React from 'react';
20
20
  import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
21
- import { useReanimatedReady } from '@umituz/react-native-animation';
22
21
 
23
22
  interface SafeBottomSheetModalProviderProps {
24
23
  children: React.ReactNode;
@@ -27,20 +26,11 @@ interface SafeBottomSheetModalProviderProps {
27
26
  /**
28
27
  * SafeBottomSheetModalProvider
29
28
  *
30
- * Delays rendering of BottomSheetModalProvider until Reanimated is ready.
31
- * This prevents layoutState.get errors during initial render.
29
+ * Wrapper around BottomSheetModalProvider for consistency.
32
30
  */
33
31
  export const SafeBottomSheetModalProvider: React.FC<SafeBottomSheetModalProviderProps> = ({
34
32
  children,
35
33
  }) => {
36
- // Use centralized Reanimated ready check from animation package
37
- const isReanimatedReady = useReanimatedReady();
38
-
39
- // Don't render BottomSheetModalProvider until Reanimated is ready
40
- if (!isReanimatedReady) {
41
- return <>{children}</>;
42
- }
43
-
44
34
  return <BottomSheetModalProvider>{children}</BottomSheetModalProvider>;
45
35
  };
46
36
 
@@ -37,7 +37,7 @@ export interface UseBottomSheetReturn {
37
37
  /**
38
38
  * Ref to attach to BottomSheet component
39
39
  */
40
- sheetRef: React.RefObject<BottomSheetRef>;
40
+ sheetRef: React.RefObject<BottomSheetRef | null>;
41
41
 
42
42
  /**
43
43
  * Open bottom sheet to initial index
@@ -37,7 +37,7 @@ export interface UseBottomSheetModalReturn {
37
37
  /**
38
38
  * Ref to attach to BottomSheetModal component
39
39
  */
40
- modalRef: React.RefObject<BottomSheetModalRef>;
40
+ modalRef: React.RefObject<BottomSheetModalRef | null>;
41
41
 
42
42
  /**
43
43
  * Present bottom sheet modal