Skip to content

React Native Bottom Sheet v5 released with Web support

updated

React Native Bottom Sheet v5 is now available. According to the release post, the entire gesture solution has been rewritten using React Native Gesture Handler v2, and support for React Native Web has been added to offer a simplified API across all platforms React Native supports.

The author notes that the release was delayed by increased commitments at their day job and says they will try to find someone to help maintain the project going forward.

Features

Web support. Web support had been planned since the project's start (issue #11). It became a priority once the community started adopting solutions such as Expo Web, which also gave the author an easier development setup. With v5, the library can be used on mobile web without API changes. Keyboard handling on web is listed as coming shortly, with PRs welcome. The feature is enabled by default.

Dynamic sizing. Dynamic sizing returns with no configuration required. The library calculates the height of static views and list content internally and uses it as the bottom sheet's content height. It is enabled by default.

FlashList integration. The integration with Shopify's FlashList, previously available only to sponsors, is now published for everyone. It can be used by importing BottomSheetFlashList:

import { BottomSheetFlashList } from '@gorhom/bottom-sheet'

Improvements

The snapping mechanism has been refactored from scratch. Since keyboard handling arrived in v4, users had reported the sheet snapping to wrong positions or not responding to resize events. The new implementation was built working backward from edge cases such as content resizing, container resizing and keyboard appearance.

Migration

Because dynamic sizing is on by default, existing bottom sheets may change height. The author recommends setting the enableDynamicSizing prop to false when migrating, then deciding whether to use it or to cap content height with the maxDynamicContentSize prop.

Breaking changes

  • Gesture Handler updated to v2
  • Reanimated updated to v3
  • enableDynamicSizing now defaults to true
  • stackBehavior now defaults to switch

Other changes are listed in the changelog. The post also thanks community testers and contributors, as well as Software Mansion for Reanimated and Gesture Handler.

Source: gorhom.dev