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

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.5",
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,13 +155,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
155
155
  ) => {
156
156
  const tokens = useAppDesignTokens();
157
157
  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
158
+ // Don't render until Reanimated is ready to prevent layoutState.get errors
165
159
  const isReanimatedReady = useReanimatedReady();
166
160
 
167
161
  // Get configuration from preset or custom (must be before useImperativeHandle)
@@ -220,48 +214,31 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
220
214
  );
221
215
 
222
216
  // Expose ref methods (must be before early return to maintain hook order)
217
+ // No need to check isReanimatedReady here - component won't render if not ready
223
218
  React.useImperativeHandle(ref, () => ({
224
219
  snapToIndex: (index: number) => {
225
- if (isReanimatedReady && sheetRef.current) {
226
- sheetRef.current.snapToIndex(index);
227
- }
220
+ sheetRef.current?.snapToIndex(index);
228
221
  },
229
222
  snapToPosition: (position: string | number) => {
230
- if (isReanimatedReady && sheetRef.current) {
231
- sheetRef.current.snapToPosition(position);
232
- }
223
+ sheetRef.current?.snapToPosition(position);
233
224
  },
234
225
  expand: () => {
235
- if (isReanimatedReady && sheetRef.current) {
236
- sheetRef.current.expand();
237
- }
226
+ sheetRef.current?.expand();
238
227
  },
239
228
  collapse: () => {
240
- if (isReanimatedReady && sheetRef.current) {
241
- sheetRef.current.collapse();
242
- }
229
+ sheetRef.current?.collapse();
243
230
  },
244
231
  close: () => {
245
- if (isReanimatedReady && sheetRef.current) {
246
- sheetRef.current.close();
247
- }
232
+ sheetRef.current?.close();
248
233
  },
249
- }));
234
+ }), []);
250
235
 
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
236
+ // Don't render until Reanimated is ready
259
237
  if (!isReanimatedReady) {
260
238
  return null;
261
239
  }
262
240
 
263
- // Double-check: Ensure we have a valid config before rendering
264
- // This prevents errors if snapPoints are invalid
241
+ // Ensure valid config
265
242
  if (!config.snapPoints || config.snapPoints.length === 0) {
266
243
  return null;
267
244
  }