Created
March 20, 2018 03:46
-
-
Save matheusnascgomes/22d07b6f31df9c676682e7890ff00a06 to your computer and use it in GitHub Desktop.
Main Component
This file contains 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
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