Skip to content

Instantly share code, notes, and snippets.

@matheusnascgomes
Created March 20, 2018 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheusnascgomes/22d07b6f31df9c676682e7890ff00a06 to your computer and use it in GitHub Desktop.
Save matheusnascgomes/22d07b6f31df9c676682e7890ff00a06 to your computer and use it in GitHub Desktop.
Main Component
import React, { Component } from 'react';
import { Grid, Row, Col } from 'react-bootstrap';
import axios from 'axios';
import Header from './Header';
import Content from './Content';
import LoadMore from './LoadMore';
import Footer from './Footer';
import './styles/app.css';
const URL = 'https://www.mocky.io/v2/5a6bc16631000078341b8b77';
class App extends Component {
constructor(props) {
super(props);
this.state = {
description: '',
list: []
};
this.refresh = this.refresh.bind(this);
this.handleChange = this.handleChange.bind(this);
this.refresh();
}
async refresh() {
const response = await axios.get(URL);
this.setState({ ...this.state, list: response.data.links });
}
handleChange(e) {
this.setState({ ...this.state, description: e.target.value });
}
render() {
return (
<Grid>
<Row>
<Col md={10} mdOffset={1}>
<Header
handleChange={this.handleChange}
/>
<Content
list={this.state.list}
description={this.state.description}
/>
<LoadMore />
<Footer />
</Col>
</Row>
</Grid>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment