import React, { Component } from 'react'; const BTC_URL = 'http://54.213.83.132/hackoregon/http/oregon_individual_contributors/'; export default class App extends Component { constructor(props) { super(props); this.state = { sortOrder: 'ascending', data: [], total: '', }; } async componentDidMount() { let URL = BTC_URL + '5/'; let response = await fetch(URL); let newData = await response.json(); console.log('Our asynch/await data:', newData); // eslint-disable-line no-console this.setState({ data: newData, }); } async componentWillUpdate() { if (this.state.data.length != this.state.total) { let new_URL = BTC_URL + this.state.total + '/'; let response = await fetch(new_URL); let newData = await response.json(); console.log('Our asynch/await data:', newData); // eslint-disable-line no-console this.setState({ data: newData, }); } } onKeyDownHandler(e) { switch (e.key) { case 'Enter': { if (e.target.value === '') { return; } const newTotal = e.target.value; this.setState({ total: newTotal, }); console.log('enter pressed', this.state.total); // eslint-disable-line no-console } } } render() { return (

Individuals

this.setState({ total: e.target.value })} >

Ascending / Descending

# Payee Sum
); } } class BTCsorter extends React.Component { constructor(props) { super(props); } render() { const rows = this.props.data.map((item, idx) => { return ( {idx + 1} {item.contributor_payee} {item.sum} ); }); return ( {rows} ); } } BTCsorter.propTypes = { data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, };