Flat List renderItem width issue - reactjs

I have some flat lists in my app with an item width of 160. For some reason when I reduce the width to 130 it will work as planned but with a width of 160px it starts to rerender again and again. What will be the possible reason for this and how to fix the issue.
My code
<FlatList
horizontal
inverted={getFlatListOrientation()}
data={data}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => renderItem(item, index)}
contentContainerStyle={styles.listContainerStyle}
showsHorizontalScrollIndicator={false}
/>
this is my render item component
<TouchableWithoutFeedback
onPress={() => {
this.onSelect();
}}
>
<View style={{ height: 168,
width: 130,
marginRight: 10,
backgroundColor: kBackgroundWhiteColor,
shadowColor: kSeparatorTintColor,
shadowOffset: { width: 1, height: 1 },
shadowOpacity: 0.5,
shadowRadius: 5,
borderRadius: 5,
elevation: 10,}>
<FastImage
style={styles.imageStyle}
resizeMode={FastImage.resizeMode.cover}
source={
loadingError
? PLACE_HOLDER_IMAGE
: {
uri: photoUrl,
priority: FastImage.priority.normal,
}
}
onLoad={() => {
this.setState({ loadingImage: false });
}}
onError={() => {
this.setState({ loadingError: true });
}}
>
<View
style={{
flexDirection: "row",
flexGrow: 1,
justifyContent: "space-between",
alignItems: "center",
transform: [
{
rotateY: isKSA() ? "180deg" : "0deg",
},
],
}}
>
<TouchableOpacity
style={{
right: 0,
bottom: 0,
position: "absolute",
}}
onPress={() => this.onAddCarTofavorites()}
>
<View style={{ paddingLeft: 8, paddingTop: 8 }}>
<View
style={{
width: 26,
height: 26,
alignItems: "center",
justifyContent: "center",
borderRadius: 13,
backgroundColor: "#00000033",
marginRight: 5,
marginBottom: 5,
}}
>
<Image
source={
isFavorited
? IC_HEART_FILLED
: IC_HEART_OUTLINE
}
style={styles.favoriteImageStyle}
backgroundColor="clear"
/>
</View>
</View>
</TouchableOpacity>
{seenCarsIdlist &&
seenCarsIdlist.indexOf(id + "") != -1 && (
<Seen />
)}
{cappasity_link && <Tag3D />}
</View>
</FastImage>
{loadingImage && (
<FastImage
style={{
...styles.mainImageStyle,
position: "absolute",
}}
resizeMode={FastImage.resizeMode.cover}
source={PLACE_HOLDER_IMAGE}
/>
)}
<View style={styles.innerContainerStyle}>
<Text
style={styles.titleTextStyle}
ellipsizeMode={"tail"}
numberOfLines={1}
>
{makeName && modelName
? `${makeName} ${modelName} ${trim}`
: `${title} ${trim}`}
</Text>
<Text style={styles.priceTextStyle}>
{price + translate("filter_label_sar")}
</Text>
<View style={{ flexDirection: "row", paddingTop: 10 }}>
<Text style={styles.yearMileageTextStyle}>
{`${year} ยท ${mileage} ${
mileageUnitTemp
? mileageUnitTemp
: mileageUnit
}`}
</Text>
</View>
</View>
</View>
</TouchableWithoutFeedback>

Related

React Native - Each action takes lot of time to perform

I have created a Login Page in my app like always. I created and when I click on Login button it takes around 30 seconds for loader to appear and meanwhile my button get hanged and blank. I don't know why my code is behaving like this.
Validate Login when click login button and show loader on button but it takes around 30 minutes
const validateLogin = () => {
console.log('validate login');
setLoader(true);
if (userName.length === 0 || password.length === 0) {
setLoader(false);
Alert.alert('Username or password cannot be empty.');
} else {
if (!netInfo.isConnected) {
setLoader(false);
Alert.alert('You are not connected to internet. Please try again.');
} else {
const token = JWTToken(userName);
getUser(token);
}
}
};
API Code
const getUser = JWTToken => {
console.log('get use');
var axios = require('axios');
var data = JSON.stringify({
username: userName.toLocaleLowerCase(),
password: password,
});
console.log('signin ', data);
var config = {
method: 'post',
url: BASE_URL + GET_USER,
headers: {
'x-jwt-token': JWTToken,
'Content-Type': 'application/json',
},
data: data,
};
axios(config)
.then(function (response) {
const res = JSON.stringify(response.data);
UI Code
<KeyboardAvoidingView
style={{
display: 'flex',
height: Dimensions.get('window').height,
width: Dimensions.get('window').width,
}}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
<SafeAreaView
style={{
flex: 1,
backgroundColor: !darkTheme
? Colors.light.backgrounColor
: Colors.dark.backgrounColor,
justifyContent: 'center',
alignItems: 'center',
}}>
<View
style={{flex: 0.2, alignItems: 'center', justifyContent: 'center'}}>
{!darkTheme ? (
<Image
source={require('../assets/images/logo.png')}
resizeMode="contain"
/>
) : (
<Image
source={require('../assets/images/logo-white.png')}
resizeMode="contain"
/>
)}
</View>
<View
style={{
alignSelf: 'center',
justifyContent: 'center',
flex: 0.7,
width: width * 0.9,
borderRadius: 20,
backgroundColor: Colors.backgroundColor,
marginHorizontal: width * 0.03,
marginBottom: height * 0.05,
padding: width * 0.03,
marginTop: height * 0.02,
}}>
<Text
style={{
color: !darkTheme
? Colors.light.textColor
: Colors.dark.textColor,
fontFamily: 'FiraSans-Medium',
fontSize: 20,
}}>
{strings.login}
</Text>
{/* Email */}
<View
style={{
flexDirection: 'row',
marginTop: height * 0.02,
width: width,
alignItems: 'center',
}}>
{!darkTheme ? (
<Image
source={require('../assets/images/email.png')}
resizeMode="contain"
/>
) : (
<Image
source={require('../assets/images/email-white.png')}
resizeMode="contain"
/>
)}
<TextInput
style={{
fontSize: 16,
fontFamily: 'OpenSans-Regular',
paddingHorizontal: width * 0.01,
color: !darkTheme ? Colors.light.black : Colors.light.white,
borderColor: !darkTheme
? Colors.light.textInputLine
: Colors.dark.white,
borderBottomWidth: 1,
width: width * 0.7,
}}
value={userName}
onChangeText={value => {
setUserName(value);
}}
// onSubmitEditing={() => onEmailSubmit()}
clearButtonMode="always"
multiline={false}
placeholder={'Username'}
placeholderTextColor={
!darkTheme ? Colors.light.black65 : Colors.light.white65
}
autoCapitalize="none"
/>
</View>
{/* Password */}
<View
style={{
flexDirection: 'row',
marginTop: height * 0.04,
width: width,
alignItems: 'center',
}}>
{!darkTheme ? (
<Image
source={require('../assets/images/password.png')}
resizeMode="contain"
/>
) : (
<Image
source={require('../assets/images/password-white.png')}
resizeMode="contain"
/>
)}
<TextInput
style={{
fontSize: 16,
fontFamily: 'OpenSans-Regular',
paddingHorizontal: width * 0.01,
color: !darkTheme ? Colors.light.black : Colors.light.white,
borderColor: !darkTheme
? Colors.light.textInputLine
: Colors.light.white,
borderBottomWidth: 1,
width: width * 0.65,
}}
value={password}
onChangeText={value => {
setPassword(value);
}}
onSubmitEditing={() => checkPassword(password)}
secureTextEntry={securePwd}
placeholder={strings.password}
placeholderTextColor={
!darkTheme ? Colors.light.black65 : Colors.light.white65
}
autoCapitalize="none"
/>
<TouchableOpacity onPress={() => setSecurePwd(!securePwd)}>
{securePwd ? (
!darkTheme ? (
<Image
source={require('../assets/images/eye-close.png')}
resizeMode="contain"
style={{width: 30, height: 20}}
/>
) : (
<Image
source={require('../assets/images/eye-close-white.png')}
resizeMode="contain"
style={{width: 30, height: 20}}
/>
)
) : !darkTheme ? (
<Image
source={require('../assets/images/eye-open.png')}
resizeMode="contain"
style={{width: 30, height: 20}}
/>
) : (
<Image
source={require('../assets/images/eye-open-white.png')}
resizeMode="contain"
style={{width: 30, height: 20}}
/>
)}
</TouchableOpacity>
</View>
<View style={{flexDirection: 'row-reverse'}}>
<TouchableOpacity onPress={goToForgotPwd}>
<Text
style={{
color: Colors.light.blueColor,
fontFamily: 'OpenSans-Regular',
fontSize: 16,
marginRight: width * 0.03,
marginTop: height * 0.005,
}}>
{strings.forgotPassword}
</Text>
</TouchableOpacity>
</View>
{/* sign Up button */}
<View
style={{
width: width * 0.3,
height: height * 0.05,
alignItems: 'center',
justifyContent: 'center',
alignSelf: 'center',
borderRadius: 25,
marginTop: height * 0.07,
backgroundColor: Colors.light.buttonBackground,
}}>
<TouchableOpacity onPress={validateLogin}>
<View>
{!loader ? (
<Text
style={{
color: Colors.light.white,
fontFamily: 'FiraSans-Regular',
fontSize: 17,
}}>
{strings.login}
</Text>
) : (
<ActivityIndicator color={Colors.light.white} />
)}
</View>
</TouchableOpacity>
</View>
</View>
<View
style={{
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}>
<Text
style={{
fontFamily: 'OpenSans-Regular',
fontSize: 16,
color: !darkTheme
? Colors.light.placeholderColor
: Colors.light.white,
marginRight: width * 0.01,
}}>
{strings.noSignUp}
</Text>
<TouchableOpacity onPress={goToRegister}>
<Text
style={{
fontFamily: 'OpenSans-Regular',
fontSize: 16,
color: Colors.light.blueColor,
}}>
{strings.register}
</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
</KeyboardAvoidingView>
Please help as I am not able to understand why I am having this issue.

Keyboard closed on click on button in react native

I have creating a comment modal in which user can add comment. This section has a list of comments and a text input field to enter comments and a button to submit comment but the problem is the I enter something in text input and then press button to submit comment but first time it closes the keyboard and then I need to press button again to add the text into the array.
My problem is why I need to press two times. Why on first time my keyboard got closed.
<KeyboardAvoidingView
style={{
display: "flex",
height: Dimensions.get("window").height,
width: Dimensions.get("window").width,
}}
behavior={Platform.OS === "ios" ? "padding" : "height"}
>
<SafeAreaView
style={{
backgroundColor: "transparent",
flex: 1,
}}
>
<View
style={{ flex: 0.4, backgroundColor: "#000", opacity: 0.2 }}
></View>
<View
style={{
flex: 0.6,
backgroundColor: Colors.dark.text,
borderRadius: 20,
}}
>
<View
style={{
flexDirection: "row",
marginTop: "3%",
paddingVertical: height * 0.005,
marginVertical: "4%",
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
paddingHorizontal: "3%",
}}
>
<View style={{ flexDirection: "column", width: width * 0.8 }}>
<Text
style={{
fontFamily: "Roboto_700Bold",
fontSize: 10,
color: Colors.light.text,
opacity: 0.4,
}}
>
COMMENTS
</Text>
<Text
style={{
fontFamily: "Roboto_700Bold",
fontSize: 20,
marginTop: height * 0.01,
}}
>
{title}
</Text>
</View>
<TouchableOpacity
onPress={() => setCommentVisible(false)}
style={{
width: width * 0.15,
alignItems: "center",
justifyContent: "center",
}}
>
<SvgRedCross />
</TouchableOpacity>
</View>
<View
style={{
flex: 0.002,
backgroundColor: Colors.light.postText,
opacity: 0.2,
}}
>
<Text></Text>
</View>
<View style={{ flex: 0.87 }}>
<FlatList
data={allComment}
showsVerticalScrollIndicator={false}
keyExtractor={(item, index) => item.id}
key={(item, index) => item.qId}
renderItem={({ item, index }) => (
<View>
<View style={{ flexDirection: "column", padding: "3%" }}>
<Text
style={{
color: "#151617",
fontFamily: "Roboto_700Bold",
fontSize: 14,
}}
>
{item.name}{" "}
</Text>
<Text
style={{
color: "#151617",
fontFamily: "Roboto_400Regular",
fontSize: 13,
}}
>
{item.comment}{" "}
</Text>
</View>
<View
style={{
height: 0.5,
backgroundColor: Colors.light.postText,
opacity: 0.2,
marginTop: "3%",
}}
>
<Text></Text>
</View>
</View>
)}
style={{}}
pagingEnabled={false}
showsHorizontalScrollIndicator={false}
/>
</View>
<View
style={{
height: height * 0.08,
elevation: 2,
backgroundColor: "#fff",
flexDirection: "row",
alignItems: "center",
borderColor: Colors.light.tabSelection,
shadowColor: Colors.light.tabSelection,
shadowOffset: {
width: 0,
height: -3,
},
shadowRadius: 1,
shadowOpacity: 0.4,
position: "absolute",
bottom: 0,
flex: 0.2,
}}
>
<TextInput
style={{
fontWeight: "300",
fontStyle: "normal",
fontSize: 13,
fontFamily: "Roboto_400Regular",
paddingLeft: "5%",
paddingLeft: "5%",
color:
theme === true
? Colors.dark.postDateText
: Colors.light.postDateText,
width: "80%",
}}
value={comment}
onChangeText={(value) => {
setComment(value);
}}
maxLength={150}
clearButtonMode="always"
multiline={true}
placeholder="Write your comments here..."
placeholderTextColor={Colors.light.postDateText}
onSubmitEditing={() => Keyboard.dismiss()}
/>
//button code to submit comment
<TouchableOpacity
onPress={() => {
addComment(comment);
// Keyboard.dismiss();
}}
style={{ width: "20%", marginLeft: 10 }}
>
<SvgCommentArrow />
</TouchableOpacity>
</View>
</View>
</SafeAreaView>
</KeyboardAvoidingView>
It may happened due to not specifying the keyboard type in the textinput props https://reactnative.dev/docs/textinput#keyboardtype.
also refer this
https://reactnative.dev/docs/keyboard

KeyboardAvoidingView is not adjusting height

Im trying to get my text view and button to center when the Keyboard is summoned.
I tried wrapping my SafeArea with KeyboardAvoidingView but that did not seem to work.
I also tried setting the KeyBoardAvoidingView behavior to position which also did not work.
Any guidance would be appreciated.
KeyboardAvoidingView does not seem to work as expected.
**Whats happening : **
**Heres my code : **
<SafeAreaView style={{ flex: 1, backgroundColor: '#376772' }}>
<KeyboardAvoidingView
style={{ flex: 1 }}
behavior={Platform.Os == 'ios' ? 'padding' : null}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{ flex: 1 }}>
<MapView
style={{ flex: 0.6 }}
showsMyLocationButton={true}
showsUserLocation={true}
followsUserLocation={lock}
onTouchStart={() => {
set(false)
}}
onPress={(loc) => {
setLocation(loc.nativeEvent.coordinate)
}}
>
<Marker coordinate={location} />
</MapView>
<Fragment>
<View
style={{
alignSelf: 'center',
alignContent: 'center',
backgroundColor: '#202B35',
padding: 10,
paddingHorizontal: 35,
margin: 5,
borderRadius: 5,
alignItems: 'center',
position: 'absolute',
}}
>
<View style={{ flexDirection: 'row' }}>
<Badge
status="error"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
marginBottom: 5,
}}
>
New Crossing
</Text>
<Text
style={{
color: '#fff',
fontSize: 10,
padding: 5,
}}
>
(Tap to add)
</Text>
</View>
<View style={{ flexDirection: 'row' }}>
<Badge
status="primary"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
}}
>
{'Existing Crossings'}
</Text>
</View>
</View>
</Fragment>
<View
style={{
flex: 0.4,
backgroundColor: '#376772',
margin: 5,
borderRadius: 5,
}}
>
<Input
placeholder="Enter Crossing name here"
inputStyle={{ color: 'orange' }}
rightIcon={
<Icon
name="edit"
size={25}
color="orange"
/>
}
placeholderTextColor={'orange'}
errorStyle={{ color: 'red' }}
/>
<Button
buttonStyle={{
margin: 10,
top: scale(10),
padding: 15,
backgroundColor: '#5cb85c',
borderRadius: 4,
}}
icon={
<Icon name="send" size={15} color="white" />
}
iconRight
titleStyle={{ fontWeight: 'bold' }}
title="Submit "
/>
</View>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
Setting behavior to "position" worked for me by removing flex: 1 from styles, like
<KeyboardAvoidingView behavior="position">
{children}
</KeyboardAvoidingView>
Cheers!

On adding viewpager videos are not getting displayed

I have used a flatlist to list 4 videos getting fetched from an API, however I want them to scroll one at a time, hence added viewpager to render each video as a separate page, however on adding viewpager I do not seem to retrieve the videos on front-end, however they are appearing on my logs.
Code with viewpager:
<ViewPager scrollEnabled={true} orientation={"vertical"} >
<FlatList
data={this.state.data.product}
scrollEventThrottle={1}
onEndThreshold={0}
renderItem={({ item }) => (
<View style = {{alignContent: 'stretch'}} >
<ScrollView scrollEventThrottle={1}>
<ViewportAwareVideo
repeat paused={this.state.videoPaused}
source={{ uri: item.urlVid }}
resizeMode = "cover"
preTriggerRatio={PRE_TRIGGER_RATIO}
retainOnceInViewport={false}
style={{width: width, height:height}}
innerRef={ref => this._videoRef = ref}
onViewportEnter={() => this._videoRef.play()}
onViewportLeave={() => this._videoRef.stop()}
/>
</ScrollView>
<View
style={{
position: 'absolute',
flexDirection: 'column',
alignItems: 'flex-end',
top: '50%',
right: 10,
}}>
<TouchableOpacity
onPress= {() => this.onButtonPress(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon
name="heart"
size={30}
color={this.state.likedItemIds.includes(item._id) ? "red" : "white"}
/>
</TouchableOpacity>
<TouchableOpacity
onPress={()=>this.shareProduct(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="share" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="whatsapp" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
onPress= {() => this.download(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="download" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
</View>
<View
style={{
position: 'absolute',
flexDirection: 'column',
top: '90%',
left: 10,
}}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Product', {_id: item._id})}>
<View
style={{
flexDirection: 'row',
}}>
<Text
style={{ fontWeight: 'bold', fontSize: 20, color: 'white' }}>
{item.title} - {item.price}
</Text>
</View>
</TouchableOpacity>
</View>
</View>
)}
keyExtractor={ item => item._id}
/>
</ViewPager>
Please help me, and let me know why is it so?

React Native Flatlist Example

HOW CAN I HANDLE MUCH DATA IN REACT NATIVE FLATLIST?
Is there anyone who can offer an example using React Native Flatlist's ScrollToIndex?
I am working with ScrollToIndex and getItemLayout but it's not working.
There are 185 items on my flatlist and when I have called ScrollToIndex(150), there's no result.
I have worked with Google for getting ScrollToIndex Example but there's nothing.
Thanks for your help.
Here's my code:
<FlatList
ref={ref => setFlatListRef(ref)}
// getItemLayout={getItemLayout}
data={markers}
keyExtractor={(item, index) => index}
ItemSeparatorComponent={() => <Separator color={colors.separator} />}
renderItem={renderItem}
style={{ flex: 1 }}
getItemLayout={getItemLayout}
/>
const getItemLayout = (data, index) => {
return {
length: 120,
offset: 120 * index,
index
}
}
const renderItem = ({ item }) => <MyListItem {...props} item={item} />
class MyListItem extends React.PureComponent {
render () {
console.log('purecom')
let cost = null
if (this.props.item.minCost != -1 && this.props.item.maxCost != -1) {
const entities = new Entities()
if (this.props.item.minCost == 0 && this.props.item.maxCost == 0) {
cost = 'Guide price: Free'
} else if (
this.props.item.minCost == this.props.item.maxCost &&
this.props.countries[this.props.item.countryID] &&
this.props.countries[this.props.item.countryID].currencySymbol
) {
cost =
`Guide price: ` +
entities.decode(
this.props.countries[this.props.item.countryID].currencySymbol
) +
`${this.props.item.minCost.toFixed(2)}`
} else {
if (
this.props.countries[this.props.item.countryID] &&
this.props.countries[this.props.item.countryID].currencySymbol
) {
cost =
`Guide price from` +
entities.decode(
this.props.countries[this.props.item.countryID].currencySymbol
) +
`${this.props.item.minCost.toFixed(2)} to` +
entities.decode(
this.props.countries[this.props.item.countryID].currencySymbol
) +
`${this.props.item.maxCost.toFixed(2)}`
}
}
}
return (
<TouchableOpacity
style={{
padding: 5,
height: 120,
backgroundColor:
this.props.selectedMarkerID !== this.props.item.ID.toString()
? '#fff'
: colors.separator
}}
activeOpacity={1}
onPress={() => this.props.selectItem(this.props.item)}
>
<Text style={{ fontWeight: 'bold', fontSize: 13 }}>
{this.props.item.Name}
</Text>
<Text style={{ marginTop: 1, fontSize: 12 }}>
{this.props.item.desc}
</Text>
<Text style={{ marginTop: 1, fontSize: 12 }}>
{this.props.markerTypes ? (
this.props.markerTypes[this.props.item.Type].ShortDescription
) : (
''
)}
</Text>
<View style={{ flexDirection: 'row', marginTop: 5 }}>
<View style={{ marginRight: 2 }}>
<MyCustomMarker
source={{ url: markerTypesImages[this.props.item.Type] }}
style={{ width: 25, height: 30 }}
userFavourites={this.props.userFavourites}
Type={this.props.item.Type}
markerID={this.props.item.ID}
/>
<Image
source={{ url: images.compass }}
style={{
marginTop: 2,
width: 20,
height: 20,
marginLeft: 5,
transform: [
{ rotate: `${this.props.item.rotate.toString()}deg` }
]
}}
/>
<Text style={{ fontSize: 9 }}>{this.props.item.distance}km</Text>
</View>
{this.props.item.thumb === '' ? (
<Image
source={{ url: images.noThumb }}
style={{ flex: 0.2, width: 84, height: 65 }}
/>
) : (
<Image
source={{
url: `${this.props.url}${this.props.item.thumb}`
}}
style={{ flex: 0.2, width: 80, height: 60 }}
/>
)}
<View style={{ flex: 0.5 }}>
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
{Object.keys(facilities).map((key, i) => {
if (this.props.item[key] === 1) {
return (
<View
style={{
width: 26,
height: 26,
padding: 2,
margin: 2,
alignItems: 'center',
borderRadius: 3,
borderWidth: 1,
borderColor: colors.dark,
backgroundColor: 'white'
}}
key={key}
>
<Image
source={{ url: facilities[key] }}
style={{ width: 20, height: 20 }}
/>
</View>
)
}
return null
})}
</View>
<StarRatingBar
continuous={true}
score={this.props.item.score / 2}
allowsHalfStars={true}
accurateHalfStars={true}
dontShowScore={true}
/>
<View>
{cost ? <Text style={{ fontSize: 12 }}>{cost}</Text> : null}
{this.props.item.open ? (
<Text style={{ color: this.props.item.style, fontSize: 12 }}>
{this.props.item.open}
</Text>
) : null}
</View>
</View>
</View>
</TouchableOpacity>
)
}
}
setFlatListRef(flatListRef) {
this.setState({ flatListRef })
}
if (index >= 0) {
this.setState({ selectedIndex: index })
setTimeout(() => {
this.state.flatListRef.scrollToIndex({
index,
viewPosition: 0.5
})
}, 100)
}

Resources