dev-resources.site
for different kinds of informations.
Flat list horizontal all Items perfectly visible in iOS not in android ContentContainerStyle
Published at
1/14/2025
Categories
reactnative
javascript
flatlist
Author
vaibhav_shukla_newsletter
Author
25 person written this
vaibhav_shukla_newsletter
open
Here is A Code
<FlatList
horizontal={isHorizontal}
contentContainerStyle={{
// width: isHorizontal ? 274 : '100%',
paddingHorizontal:10
}}
overScrollMode="never"
style={styles.frameGroup}
data={[1, 2, 3, 4, 5]}
renderItem={renderItem2}
ItemSeparatorComponent={
<View
style={{
width: isHorizontal ? 24 : 0,
height: !isHorizontal ? 60 : 0,
}}
/>
}
/>
Expected View :
Here is Code after removing width from contentContainer style
import React from 'react';
import { FlatList, View, Text, StyleSheet, Dimensions } from 'react-native';
const data = [...Array(10).keys()].map((_, i) => ({ id: i, name: `Item ${i + 1}` }));
const ITEM_WIDTH = 100;
const YourComponent = ({ item }) => (
<View style={styles.item}>
<Text>{item.name}</Text>
</View>
);
const App = () => {
return (
<FlatList
data={data}
horizontal
keyExtractor={(item) => item.id.toString()}
renderItem={({ item }) => <YourComponent item={item} />}
showsHorizontalScrollIndicator={false}
contentContainerStyle={{ paddingHorizontal: 10 }}
ItemSeparatorComponent={() => <View style={{ width: 10 }} />}
getItemLayout={(data, index) => ({
length: ITEM_WIDTH,
offset: ITEM_WIDTH * index,
index,
})}
/>
);
};
const styles = StyleSheet.create({
item: {
width: ITEM_WIDTH,
height: 100,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0',
marginHorizontal: 5,
},
});
export default App;
Why It Works After Commenting width:
- The FlatList dynamically calculates the width of the content based on its children.
- No padding offsets are added, so there's no risk of incorrect scrollable area calculation.
- As a result, horizontal scrolling works as expected.
reactnative Article's
30 articles in total
Using Direct Line botframework in a React Native Application to connect to Copilot Studio Agent
read article
[Video]Build a Full-Stack Mobile App with React Native Expo and Payload CMS in 2025!
read article
Introducing EAS Hosting: Simplified deployment for modern React apps
read article
Auto Resize multiline TextInput in React Native
read article
Read Text Asset File in Expo
read article
Flat list horizontal all Items perfectly visible in iOS not in android ContentContainerStyle
currently reading
Building High-Performance React Native Apps[Tips for Developers]
read article
React Native With TypeScript: Everything You Need To Know
read article
Building the 'One of a Kind' Ultimate Mobile App Framework. Seeking exceptional engineers to join the journey.
read article
Ship mobile apps faster with React-Native-Blossom-UI
read article
Encryption in React Native apps enhances data security, protecting user information and ensuring privacy. However, it also presents challenges, such as performance overhead and complex implementation
read article
How to Integrate Stack, Bottom Tab, and Drawer Navigator in React Native
read article
π Seamless Multi-Language Support in React Native
read article
Mastering React Native with TypeScript: From Basics to Brilliance - Part 1
read article
Building "Where Am I?": A GeoGuessr Alternative for Mobile
read article
React Native is powerful modern technology
read article
How to Build a Centered Input Field for Amounts in React Native
read article
Compound Component pattern in react
read article
Pop Quiz: Is There a Bug in This React Native Component?
read article
The Unlikely Fix: How a Simple Folder Change Saved My React Native Journey
read article
How to Integrate Stack and Bottom Tab Navigator in React Native
read article
How to make a view expand downwards in an inverted FlatList?
read article
Building a Custom Star Rating Component in React Native with Sliding and Press Interactions
read article
Choosing the Right Compiler for React Native Development in 2025
read article
Simple remove transition animation in react native
read article
How to Hire Dedicated React Native Developers for Customizable Features
read article
React Nativeβs New Architecture: Sync and async rendering
read article
Top Mobile App Development Company in Bangalore | Hyena IT
read article
Mastering Import Order in React: A Deep Dive Into Best Practices and Tools
read article
Creating Custom Inputs for Regex Validation in React and React Native
read article
Featured ones: