Skip to content

Instantly share code, notes, and snippets.

@JosephShering
Forked from caoakleyii/gist:ee1916cc3bbec33b9807bac129c9fa36
Last active March 29, 2016 20:37
Show Gist options
  • Save JosephShering/add3668dfe84712651e36df7a96c46a4 to your computer and use it in GitHub Desktop.
Save JosephShering/add3668dfe84712651e36df7a96c46a4 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import Party from './Party.jsx';
class App extends Component {
constructor(props) {
super(props);
this.state = {
parties: []
};
}
componentWillMount() {
//Ajax like a beast
myajax.get('/parties', parties => this.setState({ parties }));
}
mapParties(party, index) {
return (
<li key={index}>
{party.name}
</li>
);
}
render() {
const {parties} = this.state;
return(
<div className="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{parties.map(this.mapParties.bind(this))}
</ul>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment