@umituz/react-native-bottom-sheet 1.2.2 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-bottom-sheet",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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,11 +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
- // CRITICAL: This must be true before GorhomBottomSheet is rendered
158
+ // CRITICAL: Use centralized Reanimated ready check from animation package
159
+ // This must be true before GorhomBottomSheet is rendered
160
160
  // Otherwise, internal hooks (useAnimatedLayout) will access containerLayoutState.get
161
161
  // before Reanimated is ready, causing "containerLayoutState.get is not a function" errors
162
- const isMounted = useReanimatedReady();
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();
163
166
 
164
167
  // Get configuration from preset or custom (must be before useImperativeHandle)
165
168
  const config: BottomSheetConfig = useMemo(() => {
@@ -219,38 +222,41 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
219
222
  // Expose ref methods (must be before early return to maintain hook order)
220
223
  React.useImperativeHandle(ref, () => ({
221
224
  snapToIndex: (index: number) => {
222
- if (isMounted) {
223
- sheetRef.current?.snapToIndex(index);
225
+ if (isReanimatedReady && sheetRef.current) {
226
+ sheetRef.current.snapToIndex(index);
224
227
  }
225
228
  },
226
229
  snapToPosition: (position: string | number) => {
227
- if (isMounted) {
228
- sheetRef.current?.snapToPosition(position);
230
+ if (isReanimatedReady && sheetRef.current) {
231
+ sheetRef.current.snapToPosition(position);
229
232
  }
230
233
  },
231
234
  expand: () => {
232
- if (isMounted) {
233
- sheetRef.current?.expand();
235
+ if (isReanimatedReady && sheetRef.current) {
236
+ sheetRef.current.expand();
234
237
  }
235
238
  },
236
239
  collapse: () => {
237
- if (isMounted) {
238
- sheetRef.current?.collapse();
240
+ if (isReanimatedReady && sheetRef.current) {
241
+ sheetRef.current.collapse();
239
242
  }
240
243
  },
241
244
  close: () => {
242
- if (isMounted) {
243
- sheetRef.current?.close();
245
+ if (isReanimatedReady && sheetRef.current) {
246
+ sheetRef.current.close();
244
247
  }
245
248
  },
246
249
  }));
247
250
 
248
- // CRITICAL: Don't render GorhomBottomSheet until Reanimated is fully ready
249
- // GorhomBottomSheet's internal hooks (useAnimatedLayout, useAnimatedDetents, etc.)
250
- // access Reanimated's containerLayoutState.get during initialization
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
251
256
  // If we render before Reanimated is ready, we get "containerLayoutState.get is not a function" errors
257
+ //
252
258
  // IMPORTANT: All hooks must be called before this early return to maintain hook order
253
- if (!isMounted) {
259
+ if (!isReanimatedReady) {
254
260
  return null;
255
261
  }
256
262
 
@@ -218,14 +218,11 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
218
218
  // Expose ref methods (must be before early return to maintain hook order)
219
219
  React.useImperativeHandle(ref, () => ({
220
220
  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
221
224
  if (isMounted && modalRef.current) {
222
- // @gorhom/bottom-sheet's present() automatically opens from bottom to first snap point
223
- // Use requestAnimationFrame to ensure the component is fully ready
224
- requestAnimationFrame(() => {
225
- if (modalRef.current) {
226
- modalRef.current.present();
227
- }
228
- });
225
+ modalRef.current.present();
229
226
  }
230
227
  },
231
228
  dismiss: () => {