Created
August 26, 2016 22:33
-
-
Save Sammyjroberts/bd22c3ad90379a113d888ad33bacf411 to your computer and use it in GitHub Desktop.
component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {render} from 'react-dom'; | |
import InvoicePickTable from './invoice-pick-table.jsx'; | |
import InvoiceSelectedTable from './invoice-selected-table.jsx'; | |
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
invoices:[], | |
selectedInvoices:[] | |
}; | |
this.selected = {}; | |
} | |
getInvoiceData(){ | |
return new Promise(function(resolve, reject) { | |
console.log("hi"); | |
resolve([{number: "1"},{number: "2"},{number: "3"}]); | |
}) | |
} | |
componentDidMount() { | |
const self = this; | |
self.getInvoiceData() | |
.then((response) => { | |
self.state.invoices = response; | |
console.log(self.state); | |
}) | |
.catch((err) => { | |
console.error(err); | |
}) | |
} | |
render () { | |
return ( | |
<div> | |
<p>Selected: | |
{ | |
function() {return JSON.parse(this.selected)} | |
} | |
</p> | |
<InvoicePickTable invoices = {this.state.invoices} selected = {this.selected} /> | |
<button>Move</button> | |
<InvoiceSelectedTable selectedInvoices = {this.state.selectedInvoices} /> | |
</div> | |
); | |
} | |
} | |
render(<App/>, document.getElementById('app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment