Created
December 13, 2018 21:56
-
-
Save Franckapik/4750ce969d353fd5ca6f4385298a6741 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Shop extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
data: [] | |
}; | |
} | |
componentDidMount() { | |
fetch('/shop/getData') | |
.then(response => response.json()) | |
.then(data =>{ | |
this.setState({ data }); | |
console.log(data); | |
}); | |
} | |
render() { | |
return ( | |
<ul> | |
{this.state.data.map(function(listValue){ | |
return <li key={listValue + 'key'}>{listValue}</li>; | |
})} | |
</ul> | |
) | |
} | |
} | |
ReactDOM.render(<Shop />, document.getElementById('shop')) |
Author
Franckapik
commented
Dec 13, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment