Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. import React from 'react';
  2. import {render} from 'react-dom';
  3. import InvoicePickTable from './invoice-pick-table.jsx';
  4. import InvoiceSelectedTable from './invoice-selected-table.jsx';
  5.  
  6. class App extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. invoices:[],
  11. selectedInvoices:[]
  12. };
  13. this.selected = {};
  14. }
  15.  
  16. getInvoiceData(){
  17. return new Promise(function(resolve, reject) {
  18. console.log("hi");
  19. resolve([{number: "1"},{number: "2"},{number: "3"}]);
  20. })
  21.  
  22. }
  23. componentDidMount() {
  24. const self = this;
  25. self.getInvoiceData()
  26. .then((response) => {
  27. self.state.invoices = response;
  28. console.log(self.state);
  29. })
  30. .catch((err) => {
  31. console.error(err);
  32. })
  33. }
  34. render () {
  35. return (
  36. <div>
  37. <p>Selected:
  38. {
  39. function() {return JSON.parse(this.selected)}
  40. }
  41. </p>
  42. <InvoicePickTable invoices = {this.state.invoices} selected = {this.selected} />
  43. <button>Move</button>
  44. <InvoiceSelectedTable selectedInvoices = {this.state.selectedInvoices} />
  45. </div>
  46.  
  47. );
  48. }
  49. }
  50.  
  51. render(<App/>, document.getElementById('app'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement