@umituz/react-native-bottom-sheet 1.2.1 → 1.2.3

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.1",
3
+ "version": "1.2.3",
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",
@@ -155,8 +155,14 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
155
155
  ) => {
156
156
  const tokens = useAppDesignTokens();
157
157
  const sheetRef = React.useRef<GorhomBottomSheet>(null);
158
- // Use centralized Reanimated ready check from animation package
159
- const isMounted = useReanimatedReady();
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();
160
166
 
161
167
  // Get configuration from preset or custom (must be before useImperativeHandle)
162
168
  const config: BottomSheetConfig = useMemo(() => {
@@ -216,36 +222,47 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
216
222
  // Expose ref methods (must be before early return to maintain hook order)
217
223
  React.useImperativeHandle(ref, () => ({
218
224
  snapToIndex: (index: number) => {
219
- if (isMounted) {
220
- sheetRef.current?.snapToIndex(index);
225
+ if (isReanimatedReady && sheetRef.current) {
226
+ sheetRef.current.snapToIndex(index);
221
227
  }
222
228
  },
223
229
  snapToPosition: (position: string | number) => {
224
- if (isMounted) {
225
- sheetRef.current?.snapToPosition(position);
230
+ if (isReanimatedReady && sheetRef.current) {
231
+ sheetRef.current.snapToPosition(position);
226
232
  }
227
233
  },
228
234
  expand: () => {
229
- if (isMounted) {
230
- sheetRef.current?.expand();
235
+ if (isReanimatedReady && sheetRef.current) {
236
+ sheetRef.current.expand();
231
237
  }
232
238
  },
233
239
  collapse: () => {
234
- if (isMounted) {
235
- sheetRef.current?.collapse();
240
+ if (isReanimatedReady && sheetRef.current) {
241
+ sheetRef.current.collapse();
236
242
  }
237
243
  },
238
244
  close: () => {
239
- if (isMounted) {
240
- sheetRef.current?.close();
245
+ if (isReanimatedReady && sheetRef.current) {
246
+ sheetRef.current.close();
241
247
  }
242
248
  },
243
249
  }));
244
250
 
245
- // Don't render until mounted to prevent early hook execution
246
- // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
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
+ //
247
258
  // IMPORTANT: All hooks must be called before this early return to maintain hook order
248
- if (!isMounted) {
259
+ if (!isReanimatedReady) {
260
+ return null;
261
+ }
262
+
263
+ // Double-check: Ensure we have a valid config before rendering
264
+ // This prevents errors if snapPoints are invalid
265
+ if (!config.snapPoints || config.snapPoints.length === 0) {
249
266
  return null;
250
267
  }
251
268