/** * Created by greg on 2016-06-30. */ import React, { Component } from 'react'; import { Navigator, TouchableOpacity, TouchableHighlight, ScrollView, ListView, RecyclerViewBackedScrollView, Text, View } from 'react-native'; import _ from 'lodash'; import moment from 'moment'; //import TimerMixin from 'react-timer-mixin'; //var reactMixin = require('react-mixin'); import styles from '../../styles/styles'; class History extends Component { constructor(props) { super(props); let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); if(_.isArray(this.props.data)){ ds = ds.cloneWithRows(this.props.data); } this.state = { dataSource: ds, }; } componentDidMount() {} componentWillUnmount() {} componentWillReceiveProps(newProps) { if(newProps && newProps.data && _.isArray(newProps.data)){ this.setState({ dataSource: this.state.dataSource.cloneWithRows(newProps.data), }); } } render() { return ( } /> ); } _renderRow(rowData: Object, sectionID: number, rowID: number, highlightRow: (sectionID: number, rowID: number) => void) { let m = moment(rowData.startDate); let formattedDate = m.format('MMM Do YYYY'); return ( { //this._pressRow(rowID); highlightRow(sectionID, rowID); }}> {rowData.value} {formattedDate} ); } } //reactMixin(History.prototype, TimerMixin); module.exports = History; export default History;