Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { fetch } from 'whatwg-fetch';
- class Codelist extends React.Component{
- constructor(){
- super()
- this.state = {
- codes: []
- }
- this.componentDidMount = this.componentDidMount.bind(this);
- }
- componentDidMount(){
- fetch('/codelist')
- .then((data)=>{
- console.log('somethign');
- this.setState({
- codes: data
- })
- })
- }
- render(){
- <div id='codes'>{this.state.codes.map((code)=>{
- return <div>{code}</div>
- })}</div>
- }
- }
- module.exports = Codelist;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement