Skip to content

Instantly share code, notes, and snippets.

@alperbayram
Created April 8, 2023 20:12
Show Gist options
  • Save alperbayram/62a5800daf0cbd7c35829c4a68ca7b79 to your computer and use it in GitHub Desktop.
Save alperbayram/62a5800daf0cbd7c35829c4a68ca7b79 to your computer and use it in GitHub Desktop.
Home
import React from "react";
import { Text, View, StyleSheet, SectionList } from "react-native";
const DATA = [
{
title: "Main dishes",
data: ["Pizza", "Burger", "Risotto"],
},
{
title: "Sides",
data: ["French Fries", "Onion Rings", "Fried Shrimps"],
},
{
title: "Drinks",
data: ["Water", "Coke", "Beer"],
},
{
title: "Desserts",
data: ["Cheese Cake", "Ice Cream"],
},
];
function Home() {
return (
<View style={styles.container}>
<SectionList
sections={DATA}
keyExtractor={(item, index) => item + index}
renderItem={({ item }) => (
<View style={styles.item}>
<Text style={styles.title}>{item}</Text>
</View>
)}
renderSectionHeader={({ section: { title } }) => (
<Text style={styles.header}>{title}</Text>
)}
/>
</View>
);
}
export default Home;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
},
item: {
backgroundColor: "#22D3EE",
padding: 20,
marginVertical: 8,
},
header: {
fontSize: 32,
backgroundColor: "#fff",
},
title: {
fontSize: 24,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment