Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { AppRegistry, SectionList, StyleSheet, Text, View } from 'react-native';
  3.  
  4. export default class SectionListBasics extends Component {
  5. render() {
  6. return (
  7. <View style={styles.container}>
  8. <SectionList
  9. sections={[
  10. {title: 'D', data: ['Devin']},
  11. {title: 'J', data: ['Jackson', 'James', 'Jillian', 'Jimmy', 'Joel', 'John', 'Julie']},
  12. ]}
  13. renderItem={({item}) => <Text style={styles.item}>{item}</Text>}
  14. renderSectionHeader={({section}) => <Text style={styles.sectionHeader}>{section.title}</Text>}
  15. keyExtractor={(item, index) => index}
  16. />
  17. </View>
  18. );
  19. }
  20. }
  21.  
  22. const styles = StyleSheet.create({
  23. container: {
  24. flex: 1,
  25. paddingTop: 22
  26. },
  27. sectionHeader: {
  28. paddingTop: 2,
  29. paddingLeft: 10,
  30. paddingRight: 10,
  31. paddingBottom: 2,
  32. fontSize: 14,
  33. fontWeight: 'bold',
  34. backgroundColor: 'rgba(247,247,247,1.0)',
  35. },
  36. item: {
  37. padding: 10,
  38. fontSize: 18,
  39. height: 44,
  40. },
  41. })
  42.  
  43. // skip this line if using Create React Native App
  44. AppRegistry.registerComponent('AwesomeProject', () => SectionListBasics);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement