I was referring to an online tutorial to create custom DrawerContent for my DrawerNavigator. Am using ReactNavigation v5.
Here's my minimal code:
import React from 'react';
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
import { DrawerContentScrollView, DrawerItem } from '@react-navigation/drawer';
import Icon from 'react-native-vector-icons/FontAwesome5';
export default function DrawerContent(props) {
return (
<View style={{flex:1}}>
<DrawerContentScrollView {...props}>
<View>
<DrawerItem
icon={({color, size}) => (
<Icon
name="calendar-alt"
color={color}
size={size}
solid
/>
)}
label="Home"
onPress={() => {props.navigation.navigate('Home')}}
/>
</View>
</DrawerContentScrollView>
</View>
)
}
Here's the actual tutorial I followed: https://github.com/itzpradip/react-navigation-v5-mix/blob/master/screens/DrawerContent.js
My doubt is, how can I set the color
and size
of the Icon
. I didn't understood the technique used in that line. I mean in that line, the color
and size
variable are passed to the child Icon
element from the DrawerItem
? If so, where is it defined? How can I change the values?