@umituz/react-native-bottom-sheet 1.1.6 → 1.1.7

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.6",
3
+ "version": "1.1.7",
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",
@@ -211,7 +211,33 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
211
211
  };
212
212
  }, []);
213
213
 
214
- // Expose ref methods
214
+ // Render backdrop component (must be before early return to maintain hook order)
215
+ const renderBackdrop = useCallback(
216
+ (props: BottomSheetBackdropProps) =>
217
+ enableBackdrop ? (
218
+ <BottomSheetBackdrop
219
+ {...props}
220
+ appearsOnIndex={config.backdropAppearsOnIndex ?? 0}
221
+ disappearsOnIndex={config.backdropDisappearsOnIndex ?? -1}
222
+ opacity={0.5}
223
+ pressBehavior="close"
224
+ />
225
+ ) : null,
226
+ [enableBackdrop, config.backdropAppearsOnIndex, config.backdropDisappearsOnIndex]
227
+ );
228
+
229
+ // Handle sheet changes (must be before early return to maintain hook order)
230
+ const handleSheetChange = useCallback(
231
+ (index: number) => {
232
+ onChange?.(index);
233
+ if (index === -1) {
234
+ onDismiss?.();
235
+ }
236
+ },
237
+ [onChange, onDismiss]
238
+ );
239
+
240
+ // Expose ref methods (must be before early return to maintain hook order)
215
241
  React.useImperativeHandle(ref, () => ({
216
242
  present: () => {
217
243
  if (isMounted && modalRef.current) {
@@ -248,36 +274,11 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
248
274
 
249
275
  // Don't render until mounted to prevent early hook execution
250
276
  // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
277
+ // IMPORTANT: All hooks must be called before this early return to maintain hook order
251
278
  if (!isMounted) {
252
279
  return null;
253
280
  }
254
281
 
255
- // Render backdrop component
256
- const renderBackdrop = useCallback(
257
- (props: BottomSheetBackdropProps) =>
258
- enableBackdrop ? (
259
- <BottomSheetBackdrop
260
- {...props}
261
- appearsOnIndex={config.backdropAppearsOnIndex ?? 0}
262
- disappearsOnIndex={config.backdropDisappearsOnIndex ?? -1}
263
- opacity={0.5}
264
- pressBehavior="close"
265
- />
266
- ) : null,
267
- [enableBackdrop, config.backdropAppearsOnIndex, config.backdropDisappearsOnIndex]
268
- );
269
-
270
- // Handle sheet changes
271
- const handleSheetChange = useCallback(
272
- (index: number) => {
273
- onChange?.(index);
274
- if (index === -1) {
275
- onDismiss?.();
276
- }
277
- },
278
- [onChange, onDismiss]
279
- );
280
-
281
282
  return (
282
283
  <GorhomBottomSheetModal
283
284
  ref={modalRef}