Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import React from 'react';
  2. import { fetch } from 'whatwg-fetch';
  3.  
  4. class Codelist extends React.Component{
  5. constructor(){
  6. super()
  7. this.state = {
  8. codes: []
  9. }
  10. this.componentDidMount = this.componentDidMount.bind(this);
  11. }
  12. componentDidMount(){
  13. fetch('/codelist')
  14. .then((data)=>{
  15. console.log('somethign');
  16. this.setState({
  17. codes: data
  18. })
  19. })
  20. }
  21. render(){
  22. <div id='codes'>{this.state.codes.map((code)=>{
  23. return <div>{code}</div>
  24. })}</div>
  25. }
  26. }
  27.  
  28. module.exports = Codelist;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement