Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import React from 'react';
  2. import { StyleSheet, Text, View } from 'react-native';
  3. import Contacts from 'react-native-contacts';
  4.  
  5. export default class App extends React.Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = { contacts: [] };
  9.  
  10. }
  11.  
  12. componentWillMount = () => {
  13. this.getContacts();
  14. }
  15.  
  16. getContacts = () => {
  17. Contacts.getContacts((error, contacts) => {
  18. if (error) {
  19. console.error(error);
  20. }
  21. else {
  22. this.setState({contacts});
  23. }
  24. });
  25. }
  26.  
  27. render() {
  28. return (
  29. <View style={styles.container}>
  30. <Text>Hello, Jordan Stokes.</Text>
  31. </View>
  32. );
  33. }
  34. }
  35.  
  36. const styles = StyleSheet.create({
  37. container: {
  38. flex: 1,
  39. backgroundColor: '#fff',
  40. alignItems: 'center',
  41. justifyContent: 'center',
  42. },
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement