Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- ListView
- } from 'react-native';
- var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
- export default class AwesomeProject extends Component {
- constructor(props) {
- super(props);
- this.state = {
- dataSource: 'init',
- };
- }
- componentWillMount() {
- fetch('https://facebook.github.io/react-native/movies.json')
- .then((response) => response.json())
- .then((responseJson) => {
- this.setState({ dataSource: ds.cloneWithRows(responseJson.movies) });
- })
- .catch((error) => {
- console.error(error);
- });
- }
- render() {
- return (
- <View style={styles.container}>
- <ListView
- dataSource={this.state.dataSource}
- renderRow={(rowData) => <Text>{rowData}</Text>}
- />
- </View>
- );
- }
- }
- render() {
- if (!this.props.employees.length) {
- return (
- <View>
- <Text>NO EMPLOYEES TO LIST</Text>
- </View>
- )
- }
- return (
- <ListView
- enableEmptySections
- dataSource={this.dataSource}
- renderRow={this.renderRow}
- />
- )
- }
Add Comment
Please, Sign In to add comment