@umituz/react-native-bottom-sheet 1.1.1 → 1.1.2

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.2",
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,27 @@ 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 combination of setTimeout and requestAnimationFrame
165
+ // to ensure Reanimated is fully initialized before rendering
166
+ let frameId: number;
167
+ const timer = setTimeout(() => {
168
+ // Use multiple animation frames to ensure Reanimated worklets are ready
169
+ frameId = requestAnimationFrame(() => {
170
+ requestAnimationFrame(() => {
171
+ setIsMounted(true);
172
+ });
173
+ });
174
+ }, 150); // Increased delay to ensure Reanimated is fully initialized
175
+
176
+ return () => {
177
+ clearTimeout(timer);
178
+ if (frameId) {
179
+ cancelAnimationFrame(frameId);
180
+ }
181
+ };
167
182
  }, []);
168
183
 
169
184
  // Expose ref methods
@@ -160,12 +160,27 @@ 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 combination of setTimeout and requestAnimationFrame
167
+ // to ensure Reanimated is fully initialized before rendering
168
+ let frameId: number;
169
+ const timer = setTimeout(() => {
170
+ // Use multiple animation frames to ensure Reanimated worklets are ready
171
+ frameId = requestAnimationFrame(() => {
172
+ requestAnimationFrame(() => {
173
+ setIsMounted(true);
174
+ });
175
+ });
176
+ }, 150); // Increased delay to ensure Reanimated is fully initialized
177
+
178
+ return () => {
179
+ clearTimeout(timer);
180
+ if (frameId) {
181
+ cancelAnimationFrame(frameId);
182
+ }
183
+ };
169
184
  }, []);
170
185
 
171
186
  // Expose ref methods