Skip to content

Instantly share code, notes, and snippets.

@Franckapik
Created December 13, 2018 21:56
Show Gist options
  • Save Franckapik/4750ce969d353fd5ca6f4385298a6741 to your computer and use it in GitHub Desktop.
Save Franckapik/4750ce969d353fd5ca6f4385298a6741 to your computer and use it in GitHub Desktop.
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'))
@Franckapik
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment