Skip to content

Commit

Permalink
#06
Browse files Browse the repository at this point in the history
  • Loading branch information
guilherme-toti committed May 2, 2020
1 parent 9851708 commit 6fea700
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
- Este repositório utiliza [Create React App](https://github.com/facebookincubator/create-react-app);
- Este repositório é relacionado a essa [Playlist do YouTube](https://www.youtube.com/playlist?list=PLe4SO60BV_r0hkjGFaGcmHCtmD5EUzDxM);

#### Cada **tag** diz respeito a um vídeo da série, sendo elas:
- [1.0](https://github.com/guilherme-toti/YT-React-Tutorial/tree/1.0): Tutorial de React.JS iniciante, Virtual DOM, JSX, Create React App ([Link do vídeo](https://www.youtube.com/watch?v=ghEdUzwRsHo))
- [2.0](https://github.com/guilherme-toti/YT-React-Tutorial/tree/2.0): Tutorial de React.JS Iniciante - Components, Props, State ([Link do vídeo](https://www.youtube.com/watch?v=WPYI2CcRX7c))
- [3.0](https://github.com/guilherme-toti/YT-React-Tutorial/tree/3.0): Tutorial de React.JS iniciante, Component Lifecycle, Constructor ([Link do vídeo](https://www.youtube.com/watch?v=T8tKW-4klWg))
- [4.0](https://github.com/guilherme-toti/YT-React-Tutorial/tree/4.0): Tutorial de React.JS iniciante, Render e Função Pura ([Link do vídeo](https://www.youtube.com/watch?v=oy-d8v35mVc))
- [5.0](https://github.com/guilherme-toti/YT-React-Tutorial/tree/5.0): Tutorial de React.JS iniciante, componentDidMount, Listener e Promise ([Link do vídeo](https://www.youtube.com/watch?v=dkhDfulITBc))

## Comandos principais
- [npm start](#npm-start)
- [npm test](#npm-test)
Expand Down
24 changes: 3 additions & 21 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import React, { Component } from 'react';
import axios from 'axios';
import './App.css';

class App extends Component {
constructor(props) {
super(props);

this.state = {
data: []
}
}

componentDidMount() {
axios.get('https://api.github.com/repositories')
.then(({ data }) => {
this.setState({ data })
})
}
import Repositories from './containers/Repositories'

class App extends Component {
render() {
const { data } = this.state

return (
<div className="App">
<ul>
{data.map(item => <li key={item.id}>{item.full_name}</li>)}
</ul>
<Repositories />
</div>
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/api/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import axios from 'axios'

export const listRepositories = () => axios
.get('https://api.github.com/repositories')
.then(({ data }) => data)
7 changes: 7 additions & 0 deletions src/components/Item.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const Item = ({ id, full_name }) => (
<li key={id}>{full_name}</li>
)

export default Item
30 changes: 30 additions & 0 deletions src/containers/Repositories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Component } from 'react'
import {listRepositories} from "../api/github";
import Item from "../components/Item";

class Repositories extends Component {
constructor(props) {
super(props);

this.state = {
data: []
}
}

componentDidMount() {
listRepositories()
.then(data => this.setState({ data }))
}

render() {
const { data } = this.state

return (
<ul>
{data.map(item => <Item {...item} />)}
</ul>
)
}
}

export default Repositories

0 comments on commit 6fea700

Please sign in to comment.