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

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.4",
3
+ "version": "1.1.6",
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,6 +158,35 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
158
158
  const modalRef = React.useRef<GorhomBottomSheetModal>(null);
159
159
  const [isMounted, setIsMounted] = useState(false);
160
160
 
161
+ // Get configuration from preset or custom (must be before useImperativeHandle)
162
+ const config: BottomSheetConfig = useMemo(() => {
163
+ if (customSnapPoints) {
164
+ return BottomSheetUtils.createConfig({
165
+ snapPoints: customSnapPoints,
166
+ initialIndex,
167
+ enableBackdrop,
168
+ backdropAppearsOnIndex,
169
+ backdropDisappearsOnIndex,
170
+ keyboardBehavior,
171
+ enableHandleIndicator,
172
+ enablePanDownToClose,
173
+ enableDynamicSizing,
174
+ });
175
+ }
176
+ return BottomSheetUtils.getPreset(preset);
177
+ }, [
178
+ preset,
179
+ customSnapPoints,
180
+ initialIndex,
181
+ enableBackdrop,
182
+ backdropAppearsOnIndex,
183
+ backdropDisappearsOnIndex,
184
+ keyboardBehavior,
185
+ enableHandleIndicator,
186
+ enablePanDownToClose,
187
+ enableDynamicSizing,
188
+ ]);
189
+
161
190
  // Ensure component is mounted after Reanimated is ready
162
191
  // This prevents layoutState.get errors during initial render
163
192
  // @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
@@ -185,13 +214,9 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
185
214
  // Expose ref methods
186
215
  React.useImperativeHandle(ref, () => ({
187
216
  present: () => {
188
- if (isMounted) {
189
- modalRef.current?.present();
190
- // Snap to initial index after presenting
191
- const initialIdx = initialIndex ?? config.initialIndex ?? 0;
192
- setTimeout(() => {
193
- modalRef.current?.snapToIndex(initialIdx);
194
- }, 100);
217
+ if (isMounted && modalRef.current) {
218
+ // @gorhom/bottom-sheet's present() automatically opens from bottom to first snap point
219
+ modalRef.current.present();
195
220
  }
196
221
  },
197
222
  dismiss: () => {
@@ -221,41 +246,12 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
221
246
  },
222
247
  }));
223
248
 
224
- // Don't compute config or callbacks until mounted to prevent early hook execution
249
+ // Don't render until mounted to prevent early hook execution
225
250
  // This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
226
251
  if (!isMounted) {
227
252
  return null;
228
253
  }
229
254
 
230
- // Get configuration from preset or custom
231
- const config: BottomSheetConfig = useMemo(() => {
232
- if (customSnapPoints) {
233
- return BottomSheetUtils.createConfig({
234
- snapPoints: customSnapPoints,
235
- initialIndex,
236
- enableBackdrop,
237
- backdropAppearsOnIndex,
238
- backdropDisappearsOnIndex,
239
- keyboardBehavior,
240
- enableHandleIndicator,
241
- enablePanDownToClose,
242
- enableDynamicSizing,
243
- });
244
- }
245
- return BottomSheetUtils.getPreset(preset);
246
- }, [
247
- preset,
248
- customSnapPoints,
249
- initialIndex,
250
- enableBackdrop,
251
- backdropAppearsOnIndex,
252
- backdropDisappearsOnIndex,
253
- keyboardBehavior,
254
- enableHandleIndicator,
255
- enablePanDownToClose,
256
- enableDynamicSizing,
257
- ]);
258
-
259
255
  // Render backdrop component
260
256
  const renderBackdrop = useCallback(
261
257
  (props: BottomSheetBackdropProps) =>