question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v4] BottomSheetBackdrop - appearsOnIndex of 0 fails to render backdrop (has workaround)

See original GitHub issue

Bug

  • I’m willing to provide a pull request for this issue

As of 4.1.5, the BottomSheetBackdrop does not support a value of appearsOnIndex={0}. The root cause seems to be coercion to a default of 1 from a falsey 0 value.

Environment info

Library Version
@gorhom/bottom-sheet 4.1.5
react-native 0.64.3
react-native-reanimated 2.2.4
react-native-gesture-handler 1.10.3

Steps To Reproduce

  1. Create a bottom sheet with a custom backdrop using the renderBackdrop from the example
  2. Provide the properties appearsOnIndex={0} and disappearsOnIndex={0}

Describe what you expected to happen:

  1. The backdrop should be visible on index 0

Workaround Providing a snapIndex such as snapIndex={[1, "40%"]} will work although technically the modal will be visible at the bottom of the screen. Alternatively, you can copy/paste the BottomSheetBackdrop into a new component with either new defaults or fixed coercion.

Reproducible sample code

Reproducible Snack: https://snack.expo.dev/@jakobo/bottomsheetbackdrop---appearsonindex-bug

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
IngyuTaecommented, Mar 14, 2022

You could write a custom backdrop component until the PR merged

import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet'
import React, { useMemo } from 'react'
import Animated, {
  Extrapolate,
  interpolate,
  useAnimatedStyle,
} from 'react-native-reanimated'

const CustomBackdrop = ({ animatedIndex, style }: BottomSheetBackdropProps) => {
  const containerAnimatedStyle = useAnimatedStyle(() => ({
    opacity: interpolate(
      animatedIndex.value,
      [-1, 0],
      [0, 0.5],
      Extrapolate.CLAMP
    ),
  }))

  const containerStyle = useMemo(
    () => [style, { backgroundColor: '#a8b5eb' }, containerAnimatedStyle],
    [style, containerAnimatedStyle]
  )

  return <Animated.View style={containerStyle} />
}

export default CustomBackdrop
0reactions
github-actions[bot]commented, Feb 18, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

expo - React Native bottom sheet opens when TextInput has ...
Found a fix for the problem, it looks like it had to do with the keyboard and expo. I noticed that when the...
Read more >
BottomSheetBackdrop | React Native Bottom Sheet
BottomSheetBackdrop. A pre-built BottomSheet backdrop implementation with configurable props. Props​. Inherits ViewProps from react-native . animatedIndex ​.
Read more >
react-native-bottom-sheet - bytemeta
[v4] BottomSheetBackdrop - appearsOnIndex of 0 fails to render backdrop (has workaround) · [v4] BottomSheetTextInput not draggable on Android · [v4. · [v4]...
Read more >
no-progress-bar to disable printing "Remaining time until next ...
[v4] BottomSheetBackdrop - appearsOnIndex of 0 fails to render backdrop (has workaround), 5, 2021-12-16 ; [css-anchor-1] Issues with position fallback, 3, 2022- ...
Read more >
[v4] Backdrops not displaying - react-native-bottom-sheet - GitAnswer
Backdrop components do not display unless you have 2 or more snapPoints ... props => <BottomSheetBackdrop disappearsOnIndex={-1} appearsOnIndex={0} ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found