Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created January 12, 2021 10:24
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 velotiotech/487261cce49db4e856e30c4144fde2f3 to your computer and use it in GitHub Desktop.
Save velotiotech/487261cce49db4e856e30c4144fde2f3 to your computer and use it in GitHub Desktop.
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { octokit } from './client';
function RepoList() {
const [repos, setRepos] = useState([]);
useEffect(() => {
octokit
.request('GET /orgs/:org/repos', {
org: 'octokit',
})
.then((data) => setRepos(data.data));
}, []);
return (
<div className="repo-list-container">
<h1>Repositories</h1>
<ul>
{repos.map((repo) => (
<li key={repo.id} className="repo-list-item">
<Link to={`/repo/${repo.owner.login}/${repo.name}`}>{repo.full_name}</Link>
</li>
))}
</ul>
</div>
);
}
export default RepoList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment