Github is now Partially Functional

This commit is contained in:
Camerin 2021-09-15 15:50:52 -04:00
parent b2250ebe3b
commit 0a5739e584
2 changed files with 64 additions and 0 deletions

47
src/components/Github.js Normal file
View File

@ -0,0 +1,47 @@
import React from 'react';
import { connect } from 'react-redux';
import './css/Github.css';
import {getRepos} from '../actions';
class Github extends React.Component {
componentDidMount() {
this.props.getRepos();
console.log(this.props.repos);
}
renderRepos() {
if (this.props.repos) {
const render = this.props.repos.map((repo) =>{
console.log(repo);
return (
<div className="repo">
<div><a href={repo.html_url}>{repo.name}</a></div>
<p>{repo.description}</p>
</div>
);
});
console.log(render);
return <div className="repo-list">{render}</div>;
}
return <div></div>;
}
render() {
return (
<div className="Github">
<h1>Github</h1>
<div>
{this.renderRepos()}
</div>
</div>
);
}
}
const mapStateToProps = (state) => {
return { repos: state.github.repos};
}
export default connect(mapStateToProps, { getRepos })(Github);

View File

@ -0,0 +1,17 @@
.repo {
display: flex;
flex-direction: column;
background-color: #DDDCDC;
border-radius: 10px;
padding: 10px;
align-items: center;
margin-top: 10px;
}
.repo-list {
display:flex;
flex-direction: column;
width: 50vw;
margin-left: auto;
margin-right: auto;
}