Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Created October 16, 2017 00:08
Show Gist options
  • Save AdamMc331/d9d91004c32c3e84d2f0c1ca529dbc34 to your computer and use it in GitHub Desktop.
Save AdamMc331/d9d91004c32c3e84d2f0c1ca529dbc34 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { SectionList, StyleSheet, Text, View} from 'react-native';
export default class SectionListBasics extends Component {
render() {
return (
<View style={styles.container}>
<SectionList
sections={[
{title: 'D', data: ['Devin']},
{title: 'J', data: ['Jackson', 'James', 'Jillian', 'Jimmy', 'Joel', 'John', 'Julie']}
]}
renderItem={({item}) => <Text style={styles.item}>{item}</Text>}
renderSectionHeader={({section}) => <Text style={styles.sectionHeader}>{section.title}</Text>}
keyExtractor={(item, index) => index}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 22
},
sectionHeader: {
paddingTop: 2,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 2,
fontSize: 14,
fontWeight: 'bold',
backgroundColor: 'rgba(247, 247, 247, 1.0)'
},
item: {
padding: 10,
fontSize: 18,
height: 44
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment