Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions formulus/src/navigation/MainTabNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import HomeScreen from '../screens/HomeScreen';
import FormsScreen from '../screens/FormsScreen';
Expand All @@ -10,6 +11,10 @@
const Tab = createBottomTabNavigator();

const MainTabNavigator: React.FC = () => {
const insets = useSafeAreaInsets();
const baseTabBarHeight = 60;
const tabBarHeight = baseTabBarHeight + insets.bottom;

return (
<Tab.Navigator
screenOptions={{
Expand All @@ -20,16 +25,16 @@
backgroundColor: '#FFFFFF',
borderTopWidth: 1,
borderTopColor: '#E5E5E5',
paddingBottom: 4,
paddingBottom: Math.max(insets.bottom, 4),
paddingTop: 4,
height: 60,
height: tabBarHeight,
},
}}>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarIcon: ({color, size}) => (

Check warning on line 37 in formulus/src/navigation/MainTabNavigator.tsx

View workflow job for this annotation

GitHub Actions / Formulus (React Native)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “MainTabNavigator” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true
<Icon name="home" size={size} color={color} />
),
}}
Expand Down
Loading