import React, { Component } from 'react'; import { ListView, View, Text, Button } from 'react-native'; import { connect } from 'react-redux' import { Log } from 'lib/log.js' import { reg } from 'lib/registry.js' import { ScreenHeader } from 'lib/components/screen-header.js'; import { time } from 'lib/time-utils' class LogScreenComponent extends React.Component { static navigationOptions(options) { return { header: null }; } constructor() { super(); const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => { return r1 !== r2; } }); this.state = { dataSource: ds, }; } componentWillMount() { this.resfreshLogEntries(); } resfreshLogEntries() { reg.logger().lastEntries(1000).then((entries) => { const newDataSource = this.state.dataSource.cloneWithRows(entries); this.setState({ dataSource: newDataSource }); }); } render() { let renderRow = (item) => { return ( {time.unixMsToIsoSec(item.timestamp) + ': ' + item.message} ); } // `enableEmptySections` is to fix this warning: https://github.com/FaridSafi/react-native-gifted-listview/issues/39 return (