@umituz/react-native-bottom-sheet 1.2.2 → 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.
|
|
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,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
|
-
//
|
|
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
|
-
|
|
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 (
|
|
223
|
-
sheetRef.current
|
|
225
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
226
|
+
sheetRef.current.snapToIndex(index);
|
|
224
227
|
}
|
|
225
228
|
},
|
|
226
229
|
snapToPosition: (position: string | number) => {
|
|
227
|
-
if (
|
|
228
|
-
sheetRef.current
|
|
230
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
231
|
+
sheetRef.current.snapToPosition(position);
|
|
229
232
|
}
|
|
230
233
|
},
|
|
231
234
|
expand: () => {
|
|
232
|
-
if (
|
|
233
|
-
sheetRef.current
|
|
235
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
236
|
+
sheetRef.current.expand();
|
|
234
237
|
}
|
|
235
238
|
},
|
|
236
239
|
collapse: () => {
|
|
237
|
-
if (
|
|
238
|
-
sheetRef.current
|
|
240
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
241
|
+
sheetRef.current.collapse();
|
|
239
242
|
}
|
|
240
243
|
},
|
|
241
244
|
close: () => {
|
|
242
|
-
if (
|
|
243
|
-
sheetRef.current
|
|
245
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
246
|
+
sheetRef.current.close();
|
|
244
247
|
}
|
|
245
248
|
},
|
|
246
249
|
}));
|
|
247
250
|
|
|
248
|
-
//
|
|
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
|
|
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 (!
|
|
259
|
+
if (!isReanimatedReady) {
|
|
254
260
|
return null;
|
|
255
261
|
}
|
|
256
262
|
|