Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab Height #8037

Closed
costerik opened this issue Apr 15, 2020 · 1 comment
Closed

Tab Height #8037

costerik opened this issue Apr 15, 2020 · 1 comment

Comments

@costerik
Copy link

Hey guys, is there a way to calculate the tab height?

thanks!

@marhaupe
Copy link
Contributor

You can wrap the BottomTabBar from @react-navigation/bottom-tabs in a View, set the Views onLayout prop and read its height from there. Example:

import React from 'react'
import { BottomTabBar } from '@react-navigation/bottom-tabs'
import { View } from 'react-native'
import { useAppContext } from './utils.ts'


export function TabBar(props) {
  const { setContext } = useAppContext()


  return (
    <View
      collapsable={false}
      onLayout={event => {
        const tabBarHeight = event.nativeEvent.layout.height
        
        setContext(prevContext => ({
          ...prevContext,
          tabBarHeight,
        }))
      }}
    >
      <BottomTabBar {...props} />
    </View>
  )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants