Guest User

Untitled

a guest
Apr 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. AppRegistry,
  4. StyleSheet,
  5. Text,
  6. View,
  7. ListView
  8. } from 'react-native';
  9.  
  10. var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
  11.  
  12. export default class AwesomeProject extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. dataSource: 'init',
  17. };
  18. }
  19.  
  20. componentWillMount() {
  21. fetch('https://facebook.github.io/react-native/movies.json')
  22. .then((response) => response.json())
  23. .then((responseJson) => {
  24. this.setState({ dataSource: ds.cloneWithRows(responseJson.movies) });
  25. })
  26. .catch((error) => {
  27. console.error(error);
  28. });
  29. }
  30.  
  31. render() {
  32. return (
  33. <View style={styles.container}>
  34. <ListView
  35. dataSource={this.state.dataSource}
  36. renderRow={(rowData) => <Text>{rowData}</Text>}
  37. />
  38. </View>
  39. );
  40. }
  41. }
  42.  
  43. render() {
  44. if (!this.props.employees.length) {
  45. return (
  46. <View>
  47. <Text>NO EMPLOYEES TO LIST</Text>
  48. </View>
  49. )
  50. }
  51. return (
  52. <ListView
  53. enableEmptySections
  54. dataSource={this.dataSource}
  55. renderRow={this.renderRow}
  56. />
  57. )
  58. }
Add Comment
Please, Sign In to add comment