Skip to content

Instantly share code, notes, and snippets.

@johnferrie
Created February 2, 2016 00:08
Show Gist options
  • Save johnferrie/be9eee9ed1acae44180e to your computer and use it in GitHub Desktop.
Save johnferrie/be9eee9ed1acae44180e to your computer and use it in GitHub Desktop.
import React from 'react';
import $ from 'jquery';
import config from '../config';
import Header from '../components/Header';
import Question from '../components/Question';
import Footer from '../components/Footer';
class Landing extends React.Component {
constructor() {
super();
this.state = {
questions: []
}
}
componentDidMount() {
this.serverRequest = $.get(config.api.questions, function (results) {
this.setState({
questions: results
});
}.bind(this));
}
componentWillUnmount() {
this.serverRequest.abort();
}
render() {
return (
<div className="page-wrapper">
<Header />
<main className="landing">
<ul className="listing">
{this.state.questions.map(this.renderQuestions)}
</ul>
</main>
<Footer />
</div>
)
}
renderQuestions(question) {
return <Question key={question._id} index={question._id} details={question} />;
}
}
export default Landing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment