@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.
|
|
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
|
-
|
|
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 (
|
|
220
|
-
sheetRef.current
|
|
225
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
226
|
+
sheetRef.current.snapToIndex(index);
|
|
221
227
|
}
|
|
222
228
|
},
|
|
223
229
|
snapToPosition: (position: string | number) => {
|
|
224
|
-
if (
|
|
225
|
-
sheetRef.current
|
|
230
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
231
|
+
sheetRef.current.snapToPosition(position);
|
|
226
232
|
}
|
|
227
233
|
},
|
|
228
234
|
expand: () => {
|
|
229
|
-
if (
|
|
230
|
-
sheetRef.current
|
|
235
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
236
|
+
sheetRef.current.expand();
|
|
231
237
|
}
|
|
232
238
|
},
|
|
233
239
|
collapse: () => {
|
|
234
|
-
if (
|
|
235
|
-
sheetRef.current
|
|
240
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
241
|
+
sheetRef.current.collapse();
|
|
236
242
|
}
|
|
237
243
|
},
|
|
238
244
|
close: () => {
|
|
239
|
-
if (
|
|
240
|
-
sheetRef.current
|
|
245
|
+
if (isReanimatedReady && sheetRef.current) {
|
|
246
|
+
sheetRef.current.close();
|
|
241
247
|
}
|
|
242
248
|
},
|
|
243
249
|
}));
|
|
244
250
|
|
|
245
|
-
// Don't render
|
|
246
|
-
// This
|
|
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 (!
|
|
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
|
|