@umituz/react-native-bottom-sheet 1.1.1 → 1.1.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.1.1",
3
+ "version": "1.1.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",
@@ -158,12 +158,26 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
158
158
 
159
159
  // Ensure component is mounted after Reanimated is ready
160
160
  // This prevents layoutState.get errors during initial render
161
+ // @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
162
+ // during initialization, so we need to wait for Reanimated to be fully ready
161
163
  useEffect(() => {
162
- // Use requestAnimationFrame to ensure Reanimated is initialized
163
- const timer = requestAnimationFrame(() => {
164
- setIsMounted(true);
165
- });
166
- return () => cancelAnimationFrame(timer);
164
+ // Use a longer delay to ensure Reanimated is fully initialized
165
+ // This is critical because @gorhom/bottom-sheet's internal hooks
166
+ // access layoutState.get immediately when the component renders
167
+ const timer = setTimeout(() => {
168
+ // Use multiple animation frames to ensure Reanimated worklets are ready
169
+ requestAnimationFrame(() => {
170
+ requestAnimationFrame(() => {
171
+ requestAnimationFrame(() => {
172
+ setIsMounted(true);
173
+ });
174
+ });
175
+ });
176
+ }, 300); // Increased delay to 300ms to ensure Reanimated is fully initialized
177
+
178
+ return () => {
179
+ clearTimeout(timer);
180
+ };
167
181
  }, []);
168
182
 
169
183
  // Expose ref methods
@@ -195,6 +209,12 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
195
209
  },
196
210
  }));
197
211
 
212
+ // Don't compute config or callbacks until mounted to prevent early hook execution
213
+ // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
214
+ if (!isMounted) {
215
+ return null;
216
+ }
217
+
198
218
  // Get configuration from preset or custom
199
219
  const config: BottomSheetConfig = useMemo(() => {
200
220
  if (customSnapPoints) {
@@ -250,11 +270,6 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
250
270
  [onChange, onClose]
251
271
  );
252
272
 
253
- // Don't render until Reanimated is ready to prevent layoutState errors
254
- if (!isMounted) {
255
- return null;
256
- }
257
-
258
273
  return (
259
274
  <GorhomBottomSheet
260
275
  ref={sheetRef}
@@ -160,12 +160,26 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
160
160
 
161
161
  // Ensure component is mounted after Reanimated is ready
162
162
  // This prevents layoutState.get errors during initial render
163
+ // @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
164
+ // during initialization, so we need to wait for Reanimated to be fully ready
163
165
  useEffect(() => {
164
- // Use requestAnimationFrame to ensure Reanimated is initialized
165
- const timer = requestAnimationFrame(() => {
166
- setIsMounted(true);
167
- });
168
- return () => cancelAnimationFrame(timer);
166
+ // Use a longer delay to ensure Reanimated is fully initialized
167
+ // This is critical because @gorhom/bottom-sheet's internal hooks
168
+ // access layoutState.get immediately when the component renders
169
+ const timer = setTimeout(() => {
170
+ // Use multiple animation frames to ensure Reanimated worklets are ready
171
+ requestAnimationFrame(() => {
172
+ requestAnimationFrame(() => {
173
+ requestAnimationFrame(() => {
174
+ setIsMounted(true);
175
+ });
176
+ });
177
+ });
178
+ }, 300); // Increased delay to 300ms to ensure Reanimated is fully initialized
179
+
180
+ return () => {
181
+ clearTimeout(timer);
182
+ };
169
183
  }, []);
170
184
 
171
185
  // Expose ref methods
@@ -202,6 +216,12 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
202
216
  },
203
217
  }));
204
218
 
219
+ // Don't compute config or callbacks until mounted to prevent early hook execution
220
+ // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
221
+ if (!isMounted) {
222
+ return null;
223
+ }
224
+
205
225
  // Get configuration from preset or custom
206
226
  const config: BottomSheetConfig = useMemo(() => {
207
227
  if (customSnapPoints) {
@@ -257,11 +277,6 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
257
277
  [onChange, onDismiss]
258
278
  );
259
279
 
260
- // Don't render until Reanimated is ready to prevent layoutState errors
261
- if (!isMounted) {
262
- return null;
263
- }
264
-
265
280
  return (
266
281
  <GorhomBottomSheetModal
267
282
  ref={modalRef}