-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepositoryList.tsx
35 lines (28 loc) · 960 Bytes
/
RepositoryList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useState, useEffect } from 'react';
import { RepositoryItem } from './RepositoryItem';
import '../styles/repositories.scss'
interface Repository {
name: string;
description: string;
html_url: string;
}
// https://api.github.com/orgs/rocketseat/repos
export function RepositoryList() {
const [repositories, setRepositories] = useState<Repository[]>([]);
// used, among other things, to get data from APIs
useEffect(() => {
fetch('https://api.github.com/orgs/rocketseat/repos')
.then(response => response.json())
.then(data => setRepositories(data))
}, []);
return (
<section className="repository-list">
<h1>Lista de Repositórios</h1>
<ul>
{repositories.map(repository => {
return < RepositoryItem key={repository.name} repository={repository} />;
})}
</ul>
</section>
)
}