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.

Display bottom sheet above react navigation bottom tab bar

See original GitHub issue

Ask your Question

First of all thanks for the great package, I really appreciate your work. I’m currently trying to implement it in our app, and it works great on screens without a bottom tab bar, i.e the bottom tab bar of React Navigation created with createBottomTabNavigator. Unfortunately on screens with the tab bar it looks like this:

actual

Ideally the bottom sheet should be stacked above the navigation, like this.

expected

Is this currently possible or do you have any hints how to easily do this?

Sorry, if this question already came up and I’ve missed it, but any help would be appreciated

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:27 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
gorhomcommented, Feb 9, 2021

@bo3hm you will need to use BottomSheetModal and add its provider to the root component of you application 👍

16reactions
RemyMachadocommented, Aug 26, 2021

For those of you who are still struggling, here’s a concrete example without using react-native-portal, as the author of the lib stated:

@bo3hm you will need to use BottomSheetModal and add its provider to the root component of you application

First, the provider:

// App.jsx
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'


const App = () => {
  return (
    <BottomSheetModalProvider>
      <Navigation /> // this is my app entry component (react-navigation Navigator), use yours
    </BottomSheetModalProvider>
  )
}
// Home.jsx
// inside any descendant component (e.g. App > BottomSheetModalProvider > Navigation > ** > Home)

import React, { useCallback, useMemo, useRef } from 'react'
import { BottomSheetModal } from '@gorhom/bottom-sheet'
import { View, Button, StyleSheet, Text } from 'react-native'

const Home = () => {
  const bottomSheetModalRef = useRef<BottomSheetModal>(null)

  // variables
  const snapPoints = useMemo(() => ['25%', '50%'], [])

  // callbacks
  const handlePresentModalPress = useCallback(() => {
    bottomSheetModalRef.current?.present()
  }, [])
  const handleSheetChanges = useCallback((index: number) => {
    console.log('handleSheetChanges', index)
  }, [])

  return (
    <View>
        <Button onPress={handlePresentModalPress} title="Present Modal" color="black" />
        <BottomSheetModal ref={bottomSheetModalRef} index={1} snapPoints={snapPoints} onChange={handleSheetChanges}>
          <View style={styles.contentContainer}>
            <Text>Awesome 🎉</Text>
          </View>
        </BottomSheetModal>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    justifyContent: 'center',
    backgroundColor: 'grey',
  },
  contentContainer: {
    flex: 1,
    alignItems: 'center',
  },
});

The documentation needed:

I’m using v4 (alpha).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display a bottom sheet from React navigation ...
I want to display a reanimated-bottom-sheet when I click the tabBarIcon (maybe such as button adding in picture) instead of a component. I'm ......
Read more >
How to place custom bottom sheet above bottom tab navigator?
I've built a custom bottom sheet using Reanimated2 but am having trouble placing it above the bottomTabNavigator tabbar. I need the sheet to ......
Read more >
Bottom Tabs Navigator | React Navigation
A simple tab bar on the bottom of the screen that lets you switch between different routes. Routes are lazily initialized -- their...
Read more >
Tutorial: React Native Custom Bottom Bar with BottomSheet
This will allow us to navigate to different pages within the currently selected tab. We can also set specific options for each screen....
Read more >
React Navigation 6: Hiding bottom tab on a specific screen
The Example. App Preview. This sample app contains 3 screens: Home, Product, and Contact. The bottom tab bar is only visible ...
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