So into the cartscreen, I am importing a dropdown component.
Now, there is a different dropdown inside the cartscreen called renderDropdown, and I'm using it to display two different data lists as two dropdowns for the user to choose from. Although this renderDropdown is functioning properly, selecting an imported dropdown causes the selected value in my renderDropdown to be cleared from the dropdown bar.
I verified that renderDropdown's value remains in the current state and I noticed that when I click on this imported drop-down, I get a message printed to the console(I have added console.log in cart screen whenever screen renders), which indicates that my entire screen is rendering. Could someone please look into this and let me know what's wrong?
Here is the code for a dropdown menu.
[I've also used the same component in a lot of other screens, and it works just fine]
import { StyleSheet, View } from 'react-native'
import React from 'react'
import { Dropdown} from 'react-native-element-dropdown'
import { COLORS } from '../constants'
const DropdownComponent = ({text, extractorValue, external_Id, data:mainData, extraData, value, setValue, isFocus, setIsFocus,area=false, retailer=false, retailerC=false, extraStyling}) => {
return (
<View style={[styles.container, {...extraStyling}]}>
<Dropdown
style={[styles.dropdown, isFocus && { borderColor: COLORS.blue90 }]}
placeholderStyle={styles.placeholderStyle}
selectedTextStyle={styles.selectedTextStyle}
inputSearchStyle={styles.inputSearchStyle}
iconStyle={styles.iconStyle}
data={mainData}
containerStyle={{
backgroundColor:COLORS.white10,
borderRadius:10,
marginTop:10,
borderColor:COLORS.gray10,
shadowColor:COLORS.blue90,
shadowOffset:{
height:15,
width: 15
},
elevation:19,
}}
search
maxHeight={300}
labelField={extractorValue ? extractorValue :"name"}
valueField={external_Id ? external_Id :"name"}
placeholder={!isFocus ? `Select ${text ? text : 'Item'}` : '...'}
searchPlaceholder="Search..."
value={value}
onFocus={() => setIsFocus(true)}
onBlur={() => setIsFocus(false)}
onChange={item => {
retailer ?
retailerC ?
(
setValue({...extraData, retailerClass:external_Id ? item[external_Id] : item.name})
):
(
( area ?
setValue({...extraData, area:external_Id ? item[external_Id] : item.name})
:
setValue({...extraData, route:external_Id ? item[external_Id] : item.name})
)
)
:
(
setValue(external_Id ? item[external_Id] : item.name)
)
setIsFocus(false)
}}
/>
</View>
)
}
export default DropdownComponent
and here is the cartScreen code which is causing trouble , also i want to include that i have to show 3 dropdowns on the screen so i was using the same component renderDropdown for all of them but i was having the same issue so i though it is because of third dropwdown (namely value scheme ) so i used external one but having the same issue.
const CartDetailsScreen = ({navigation}) => {
const [loading, setLoading] = React.useState(false)
const {cartItems, setCartItems } = useContext(mapContext)
const { createOrders, createOrderStatus, distributors, setDistributors, getDistributors, schemes, setSchemes, getSchemes} = useContext(commonUrlsContext)
useLayoutEffect(()=>{
navigation.setOptions({
headerShown:true,
headerTitle:'CART DETAILS',
...HeaderStyles,
headerLeft: () =>(
<HeaderLeft navigation={navigation} />
)
})
},[])
const [valueSchemeFromDropDown, setValueSchemeFromDropDown] = React.useState('')
React.useEffect(()=>{
getSchemes()
getDistributors()
return () =>{
setDistributors([])
setSchemes([])
}
},[])
React.useEffect(()=>{
if(createOrderStatus){
ToastAndroid.show('Order created successfully', ToastAndroid.CENTER)
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [
{ name: 'OrderSuccessful' },
],
})
);
setTimeout(()=>{{navigation.navigate('OrderSuccessful'), setCartItems([])}},1000)
}
},[createOrderStatus])
function RenderDropDown({index, text, data, external_Id, extractorValue, width, qtyScheme, valueScheme}){
return(
<View style={[styles.container, width && {width: width}]}>
<Dropdown
style={[styles.dropdown]}
placeholderStyle={styles.placeholderStyle}
selectedTextStyle={styles.selectedTextStyle}
inputSearchStyle={styles.inputSearchStyle}
iconStyle={styles.iconStyle}
data={data}
containerStyle={{
borderRadius:10,
marginTop:10,
borderColor:COLORS.gray10,
shadowColor:COLORS.gray90,
shadowOffset:{
height:10,
width: 10
},
elevation:15,
}}
search
maxHeight={300}
labelField={extractorValue ? extractorValue :"name"}
valueField={external_Id ? external_Id :"name"}
placeholder={`Select ${text ? text : 'item'}`}
searchPlaceholder="Search..."
// value={qtyScheme ? cartItems[index]?.distributorName}
onChange={item => {
qtyScheme ?
(
console.log(1),
cartItems[index].qtyScheme = item[external_Id],
setCartItems(cartItems)
)
:
(
console.log(2),
cartItems[index].distributorName = item[extractorValue],
cartItems[index].distributorId = item[external_Id],
setCartItems(cartItems)
)
}}
/>
</View>
)
}
const removeFromCart = (id) =>{
let updatedCart = cartItems.filter(product => product?.products?.Id !== id)
setCartItems(updatedCart)
ToastAndroid.show('Item Removed From the Cart.', ToastAndroid.SHORT)
if(updatedCart.length === 0){
navigation.goBack()
}
}
const submitHandler = () =>{
setLoading(true)
createOrders(cartItems, valueSchemeFromDropDown)
}
const reduceHandler = (item, index) =>{
if(item.qty === 1){
let newResults = cartItems.filter(product => product.products.Id !== item.products.Id)
setCartItems(newResults)
if(newResults.length === 0){
navigation.goBack()
}
}
else{
item.qty = item.qty - 1
let newResults = cartItems.filter(product => product.products.Id !== item.products.Id ? product : item)
setCartItems(newResults)
}
}
const [testValue, setTestValue] = React.useState('')
const [testFocus, setTestFocus] = React.useState(false)
const incrementHandler = (item, index) =>{
let newResults = cartItems.map(product =>
product.products.Id === item.products.Id ? {...item, qty: product.qty + 1} : product)
setCartItems(newResults)
}
return (
<>
{ loading ?
<RowCenter style={{flex:1, flexDirection: 'column', alignItems:'center'}}>
<StyledText fontSize={'20px'}>{createOrderStatus ? 'Redirecting..' : 'Loading..'}</StyledText>
</RowCenter> :
<>
<View style={{flex:0.8}}>
<ScrollView showsVerticalScrollIndicator={false}>
{cartItems?.map((item, index)=>{
return(
<View key={item?.products?.Id} style={{flexDirection:'row', padding:13, borderRadius:10, margin:10, alignItems:'center', backgroundColor:COLORS.green20, ...customShadow }}>
<View style={{width:'100%'}}>
<StyledText>Product Name : {item?.products?.Name}</StyledText>
<ExtraSpace />
{item?.products?.Description &&
<StyledText>Product Description : {item?.products?.Description?.length > 30 ? item?.products?.Description?.slice(0,30) + '...': item?.products?.Description }</StyledText>
}
<ExtraSpace />
<View style={{flexDirection:'row', justifyContent:'space-between', alignItems:'center', padding:10}}>
<TouchableOpacity onPress={()=>removeFromCart(item?.products?.Id)} style={{flexDirection:'row', justifyContent:'center', alignItems:'center'}}>
<SimpleLineIcons name="trash" size={15} color={COLORS.error} />
<StyledText color={COLORS.error}>Remove</StyledText>
</TouchableOpacity>
<View style={{width:'40%', flexDirection:'row', justifyContent:'space-between', alignItems:'center',}}>
<TouchableOpacity onPress={()=>reduceHandler(item, index)}>
<Feather name="minus-circle" size={22} color={COLORS.gray90} />
</TouchableOpacity>
<StyledText>Qty : {item?.qty}</StyledText>
<TouchableOpacity onPress={()=>incrementHandler(item, index)} >
<Feather name="plus-circle" size={22} color={COLORS.gray90} />
</TouchableOpacity>
</View>
</View>
<RenderDropDown index={index} text={'Distributor'} data={distributors?.response} external_Id='external_Id' extractorValue='name' />
{item.distributorName &&
<Label color={'#131821'}> Clone Selected : {item.distributorName}</Label>
}
<RenderDropDown id={item?.products?.id} index={index} text={'Quantity Scheme'} data={schemes?.response?.filter(scheme => scheme.Type__c === 'Quantity Scheme')} external_Id='Id' extractorValue='Name' qtyScheme={true}/>
</View>
</View>
)
})}
</ScrollView>
</View>
<View style={{flex:0.2, justifyContent:'center', alignItems:'center', borderWidth:1, borderTopLeftRadius:10, borderTopRightRadius:10, marginBottom:2, marginHorizontal:1, borderTopColor:'gray', backgroundColor:"transparent"}}>
<DropdownComponent text={'Value Scheme'} data={schemes?.response?.filter(scheme => scheme.Type__c === 'Value Scheme')} external_Id='Id' extractorValue={'Name'} value={testValue} setValue={setTestValue} isFocus={testFocus} setIsFocus={setTestFocus} extraStyling={{width: '100%', marginTop:10, marginBottom:1}}/>
{/* <RenderDropDown text={'Value Scheme'} data={valueScheme} external_Id='Id' extractorValue='Name' valueScheme={true}/> */}
<TextButton onPress={()=>{cartItems?.length === 0 ? null : submitHandler()}} componentStyling={{width:'94%', padding:8, marginHorizontal:10, marginBottom:10, marginTop:1}} title='Place Order'/>
</View>
</>
}
</>
)
}
Hey you have added these
onFocus={() => setIsFocus(true)}
onBlur={() => setIsFocus(false)}
and these are setStates , so it will re render when dropdwon opens or closes
Hope it helps. feel free for doubts
Related
output
code
import React from 'react';
import {
Text,
View,
FlatList,
ScrollView,
SafeAreaView
} from 'react-native';
import { nameData } from './dummydata';
const windowSize = FlatList.length > 50 ? FlatList.length / 4 : 21;
const Main = () => {
return (
<View style={{}}>
<SafeAreaView style={{}}>
<ScrollView style={{}}>
<FlatList
disableVirtualization={true}
//data={nameData.sort((a, b) => a.name.localeCompare(b.name))}
data={nameData.sort(function (a, b) {
return (a.name < b.name) ? -1 : (a.name > b.name) ? 1 : 0;
})}
renderItem={({ item }) => (
<Text style={{ fontSize: 20,marginLeft:10,padding:5 }}>{item.name}</Text>
)}
getItemLayout={(data, index) => ({
length: 80,
offset: 80 * index,
index,
})}
removeClippedSubviews={true}
maxToRenderPerBatch={windowSize}
windowSize={windowSize}
numColumns={1}
keyExtractor={(item, index) => String(index)}
contentContainerStyle={{ paddingBottom: 10 }}
/>
</ScrollView>
</SafeAreaView>
</View>
);
};
export default Main;
I have given the code above
my data is sorted , I want like this if data is started A alphabet then this data contain in A header section if data is started B alphabet then this data contain in B header section.
like this D header contain only D Starting data C header contain only C Starting data
but I don't know how to set header and how to set data in header section.
in sort I want like this data
anybody can give me solution?
thank you!🐼
Method 1
Try this package react-native-section-alphabet-list
A simple React Native component that takes an array of data and renders a SectionList with alphabetically (or custom) sorted data.
Method 2
Update your code like below and try
import React, { useEffect, useState } from "react";
import { Text, View, FlatList, SafeAreaView } from "react-native";
import { nameData } from "./duumydata";
const windowSize = FlatList.length > 50 ? FlatList.length / 4 : 21;
const Main = () => {
let listData = new Array(26).fill([]);
const headerArray = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
const [data, setData] = useState([]);
useEffect(() => {
nameData.sort(function (a, b) {
return a.name.toUpperCase() < b.name.toUpperCase()
? -1
: a.name > b.name
? 1
: 0;
});
headerArray.forEach((header, index) => {
nameData.forEach((item) => {
const headerText = item.name.split("")[0].toUpperCase();
if (header == headerText) {
listData[index] = [...listData[index], item];
}
});
});
setData(listData);
}, []);
const renderItem = ({ item, index }) => {
return (
<>
<View style={{ backgroundColor: "grey" }}>
<Text>{headerArray[index]}</Text>
</View>
{item?.map((obj) => renderName(obj))}
</>
);
};
const renderName = (item) => {
return (
<View>
<Text>{item.name}</Text>
</View>
);
};
return (
<View style={{}}>
<SafeAreaView style={{}}>
<FlatList
disableVirtualization={true}
data={data}
renderItem={(item) => renderItem(item)}
getItemLayout={(data, index) => ({
length: 80,
offset: 80 * index,
index
})}
removeClippedSubviews={true}
maxToRenderPerBatch={windowSize}
windowSize={windowSize}
numColumns={1}
keyExtractor={(item, index) => String(index)}
contentContainerStyle={{ paddingBottom: 10 }}
/>
</SafeAreaView>
</View>
);
};
export default Main;
I am using scrollTo to let scrollview element scroll to a particular id as follows:
let scrollviewRef = useRef();
useEffect(() => {
selectedid && selectedid!=null && selectedid!=undefined &&
scrollviewRef.current?.scrollTo({
y:selectedid,
animated:true,
})
getData();
BackHandler.addEventListener('hardwareBackPress', handleBackButtonOnnclick);
return () => {
BackHandler.removeEventListener(
'hardwareBackPress',
handleBackButtonOnnclick,
);
};
}, [changedstatus]);
<ScrollView ref={scrollviewRef}>
{data != '' &&
data !== undefined &&
data !== null &&
data.map((item) => {
const selected = item.vaccine_list
.map((a) => a.vaccineInternalId)
.includes(selectedid);
return (
<TouchableOpacity
key={item.id}
style={{
paddingLeft: 10,
paddingRight: 10,
}}
onPress={() => handleOnPress(item.id, item)}>
{expand[item.id] ? (
<ExpandedVaccineComponent
item={item}
id={id}
navigation={navigation}
changevaccinestatus={changevaccinestatus}
childdob={childdob}
/>
) : (
<NotExpandedVaccineComponent item={item} />
)}
</TouchableOpacity>
);
})}
</ScrollView>
But when I execute this, it is not initially scrolling to the selectedid, could anyone tell me what have I missed out here?
Any leads would be great.
Let me know if anything else is required for better clarity.
UPDATED POST WITH FULL CODE :
so i'm having an issue setting a state value to the result of a
filter/saying undefined evaluating dataShow.text.presentation which is the first line where i use dataShow.something.
when "dataShow" state suppose to be an object with "text" property which is also an object who contain "presentation" property.
here my code :
import { Text, View, Content, Container, Spinner, List, Header, Body, Title } from 'native-base'
import React, {useState, useContext, useEffect} from 'react'
import { AsyncStorage, ScrollView } from 'react-native';
import { ShopContext } from '../../App';
var s = require("../../styles/styles")
var l = require("../../i18n/fr")
function DetailsPage(props) {
const {shopData,setShopData} = useContext(ShopContext)
const {userFavList,setUserFavList} = useContext(ShopContext)
const [isLoading,setIsLoading] = useState(true)
const [dataShow,setDataShow] = useState([])
const [callPicture,setCallPicture] = useState('')
const [isOpen,setIsOpen] = useState(false)
//________________________________________________________________________________________________________________________
useEffect(() => {
// console.log(userFavList)
// console.log('END OF USEFAVLIST')
// console.log(shopData)//return an array of object
// console.log('END SHOPDATA')
console.log('propsName From Search Result Page : '+ props.nameFromResultsPage) // here i have selected name from parent page
const selectedData = shopData.filter(item => item.name === props.nameFromResultsPage)
console.log('selectedData : '+ selectedData)//sending [objet Objet] in console
setDataShow(dataShow => [...dataShow, selectedData])
console.log(dataShow)//Array [] in console
console.log('END DATASHOW')
setTimeout(() => {
setIsLoading(false)
}, 500);
}, [])
//________________________________________________________________________________________________________________________
// AJOUTER AU FAVORIS
function addToFav (){
let checkMyFav = AsyncStorage.getItem("userFavorites")
if(userFavList == null){
userFavList= []
} else {
userFavList = JSON.parse(userFavList)
}
userFavList.push(dataShow);
AsyncStorage.setItem("userFavorites",JSON.stringify(userFavList))
// console.log('FAV: ' + JSON.stringify(userFavList))
}
//________________________________________________________________________________________________________________________
//VOIR LA DESCRIPTION COMPLETE OU TRONQUEE
function voirPlus(){
setIsOpen(!isOpen)
}
//________________________________________________________________________________________________________________________
//LOADING SCREEN
if(isLoading === true){
return(
<Container>
<Content contentContainerStyle={{flex:1,justifyContent:'center',alignItems:'center',height:'100%'}}>
<Spinner color='#E64511'/>
</Content>
</Container>
)
}
//________________________________________________________________________________________________________________________
//PAGE DE DETAIL
if(isLoading=== false){
let presentationfull = dataShow.text.presentation
let presentationslice = presentationfull.slice(0, 150)
//________________________________________________________________________________________________________________________
return (
<ScrollView >
{isLoading === false ?
<List>
<Header style={s.header_detailPage}>
<Body>
<Title style={s.TxtcolorHeader_detailPage}>{dataShow.name}</Title>
</Body>
</Header>
{callPicture !== undefined ?
<Image source={{ uri: dataShow.media.logo.big }} style={s.img_detailPage} ></Image>
: <Image source={{ uri: dataShow.media.logo.small }} style={s.img_detailPage} ></Image>
}
<View style={s.cardContainer_detailPage}>
<Button transparent onPress={()=> addToFav()}>
<Icon style={{ color: dataShow !== true ? '#E64511' : 'grey', fontSize: 24 }} name='heart' />
<Text style={{color:'black'}}>Favoris</Text>
</Button>
<Button transparent style={s.retourBtn_detailPage}>
<Text>Retour</Text>
</Button>
<Text style={s.favDesc_detailPage}>{l.oclock_code}</Text>
<Text style={s.desc_detailPage}>{dataShow.text.opening_time}</Text>
<Text style={s.favDesc_detailPage}>{l.address_code}</Text>
<Text>{dataShow.address}</Text>
<Text >{dataShow.postalcode}, {dataShow.city}</Text>
{/* <Text style={s.color_buttonLine}>{button}</Text> */}
<Text>{l.presentation_code}</Text>
<Text>
{isOpen === false ?
<View style={{ width: 290 }}>
<Text>{presentationslice}</Text>
<Button transparent style={s.retourBtn_detailPage} onPress={() => voirPlus()}>
<Text style={{color:'black'}}>Voir plus</Text>
</Button>
</View> :
<View style={{ width: 290 }}>
<Text>{presentationfull}</Text>
<Button transparent style={s.retourBtn_detailPage} onPress={() => voirPlus()}>
<Text style={{color:'black'}}>Voir moins</Text>
</Button>
</View>
}
</Text>
<Button style={s.buttonOrange2} onPress={() => returnOrder()}>
<Text style={s.color_buttonOrange}>{l.button_shops}</Text>
</Button>
</View>
</List>
: <Text></Text>
}
</ScrollView>
)}
}
export default DetailsPage
is it a state setting error ? or my return is executed too early ?
here is one of my object:
You are missing basic dependencies in your useEffect, without them you may run its callback with staled data.
useEffect(() => {...}, [props.nameFromResultsPage,shopData]);
It should show some warnings if you using CRA with eslint.
I would like to add a searchbar in my header. I am using react-navigation, and want to create an effect like in the below 2 pictures. When you press the search icon, the hamburger icon becomes a arrow-back icon, the header title becomes a search field. I have tried to accomplish this with the navigationOptions but the problem is that it is static and it cannot be updated when an action happens on the header itself. So for experimenting what I want to accomplish is that when the search icon is pressed, the hamburger icon becomes a arrow-back icon. Thank you!
var search = false;
const menuButton = navData => (
<HeaderButtons HeaderButtonComponent={HeaderButton}>
<Item
title="Menu"
iconName="ios-menu"
onPress={() => {
navData.navigation.toggleDrawer();
}}
/>
</HeaderButtons>
);
const goBackButton = navData => (
<HeaderButtons HeaderButtonComponent={HeaderButton}>
<Item
title="Menu"
iconName="ios-arrow-back"
onPress={() => {
search=false
}}
/>
</HeaderButtons>
);
MyScreen.navigationOptions = navData => {
return {
headerTitle: 'My title',
headerLeft: search ? goBackButton : menuButton(navData),
headerRight: (
<BorderlessButton
onPress={() => search=true}
style={{ marginRight: 15 }}>
<Ionicons
name="md-search"
size={Platform.OS === 'ios' ? 22 : 25}
/>
</BorderlessButton>
)
}
};
try use state bro !
constructor(props) {
super(props);
this.state = {
search:false
}
}
const menuButton = navData => (
<HeaderButtons HeaderButtonComponent={HeaderButton}>
<Item
title="Menu"
iconName="ios-menu"
onPress={() => {
navData.navigation.toggleDrawer();
}}
/>
</HeaderButtons>
);
const goBackButton = navData => (
<HeaderButtons HeaderButtonComponent={HeaderButton}>
<Item
title="Menu"
iconName="ios-arrow-back"
onPress={() => {this.setState({search:false})}}
/>
</HeaderButtons>
);
MyScreen.navigationOptions = navData => {
return {
headerTitle: 'My title',
headerLeft: this.state.search ? goBackButton : menuButton(navData),
headerRight: (
<BorderlessButton
onPress={() => {this.setState({search:true})}}
style={{ marginRight: 15 }}>
<Ionicons
name="md-search"
size={Platform.OS === 'ios' ? 22 : 25}
/>
</BorderlessButton>
)
}
};
I have fixed it by passing information to my navigationOptions with setParams and getParam. The only problem I faced was in infinite loop which I could solve with the proper use of useEffect and useCallback.
const MyScreen = props => {
const dispatch = useDispatch();
var search = useSelector(state => state.verbs.search);
useEffect(() => {
props.navigation.setParams({search: search});
}, [search]);
const toggleSearchHandler = useCallback(() => {
dispatch(toggleSearch());
}, [dispatch]);
useEffect(() => {
props.navigation.setParams({toggleSearch: toggleSearchHandler});
}, [toggleSearchHandler]);
return (<View> ...
</View>
);
};
MyScreen.navigationOptions = navData => {
const toggleSearch = navData.navigation.getParam('toggleSearch')
return {
headerTitle: 'Verbs',
headerLeft: navData.navigation.getParam('search') ? gobackButton : menuButton(navData),
headerRight: (
<HeaderButtons HeaderButtonComponent={HeaderButton}>
<Item
title="Menu"
iconName="ios-star"
onPress={toggleSearch}
/>
</HeaderButtons>
)
}
};
the navigationOptions code like that.
static navigationOptions = ({navigation})=>({
tabBarLabel:'查看',
headerTitle:navigation.state.params.title,
tabBarIcon: ({ tintColor,focused }) => (
<Image style={SKIN.tabImage} source={focused?AppImages.MyPost.lookchoose:AppImages.MyPost.look}/>
),
});
this is my Tab componet,how I can get tabBarLabel and tabBarIcon?
export default class Tab extends Component {
renderItem = (route, index) => {
const {
navigation,
jumpToIndex,
} = this.props;
const focused = index === navigation.state.index;
const color = focused ? this.props.activeTintColor : this.props.inactiveTintColor;
return (
<TouchableOpacity
key={index}
style={styles.tabItem}
onPress={() => jumpToIndex(index)}
>
<View
style={styles.tabItem}>
{this.props.renderIcon(color,focused)}
<Text style={{ color }}>{this.props.getLabel()}</Text>
</View>
</TouchableOpacity>
);
};
render(){
console.log('Tab this.props',this.props);
const {navigation,} = this.props;
const {routes,} = navigation.state;
return (
<View style={styles.tab}>
{routes && routes.map(this.renderItem)}
</View>
);
}
}
I custom Tab,now I want use that but some bug show me.
like that,
imagebug
please help me...
try updating the render method with this code:
render(){
console.log('Tab this.props',this.props);
const {navigation,} = this.props;
const {routes,} = navigation.state;
return (
<View style={styles.tab}>
//pass down the route and the index to the renderItem function
{routes && routes.map((route,index) => this.renderItem(route, index) )}
</View>
);
renderItem = (route, index) => {
const {
navigation,
jumpToIndex,
} = this.props;
const focused = index === navigation.state.index;
const color = focused ? this.props.activeTintColor : this.props.inactiveTintColor;
let TabScene = {
focused:focused,
route:route,
tintColor:color
};
return (
<TouchableOpacity
key={route.key}
style={styles.tabItem}
onPress={() => jumpToIndex(index)}
>
<View
style={styles.tabItem}>
{this.props.renderIcon(TabScene)}
<Text style={{ color }}>{this.props.getLabel(TabScene)}</Text>
</View>
</TouchableOpacity>
);
};