Skip to content

Commit 77755e6

Browse files
author
Kevin Turney
committed
added comments and notes
1 parent fb87c33 commit 77755e6

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

app/Components/App.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Battle from './Battle';
66
import Results from './Results';
77
import { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';
88

9+
// the entry point for the app, components are wrapped in a Router component
10+
// each route renders a component
911
class App extends React.Component {
1012
render() {
1113
return (

app/Components/Battle.js

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import { Link } from 'react-router-dom';
44
import PlayerPreview from './PlayerPreview';
55

6+
// Controlled componet
67
class PlayerInput extends Component {
78
constructor(props) {
89
super(props);
@@ -52,6 +53,7 @@ PlayerInput.propTypes = {
5253
onSubmit: PropTypes.func.isRequired,
5354
};
5455

56+
/* ------- Battle owns state which is passed to PlayerPreview and PlayerInput*/
5557
class Battle extends Component {
5658
constructor(props) {
5759
super(props);
@@ -93,6 +95,8 @@ class Battle extends Component {
9395
const playerOneImage = this.state.playerOneImage;
9496
const playerTwoImage = this.state.playerTwoImage;
9597

98+
/* Player name is initially false, we render a PlayerInput component
99+
When we fetch a player, we render a reset button until Battle is clicked*/
96100
return (
97101
<div>
98102
<div className="row">

app/Components/Loading.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33

4+
// Reusable Component, has default props if not user config'd
45
const styles = {
56
content: {
67
textAlign: 'center',

app/utils/api.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import axios from 'axios';
44

5+
// in case of rate limiting when hitting the github api
56
const id = 'YOUR CLIENT ID';
67
const sec = 'YOUR SECRET ID';
78
const params = '?clent_id=' + id + '&client_secret=' + sec;
@@ -34,7 +35,8 @@ const handleError = error => {
3435
return null;
3536
};
3637

37-
// composition of functions
38+
// composition of functions, pass in array of functions, when results come back
39+
// we process data, each will return an object(net is an array of objects)
3840
const getUserData = player => {
3941
return axios.all([getProfile(player), getRepos(player)]).then(data => {
4042
const profile = data[0];

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let config = {
2626
],
2727
};
2828

29+
// conditional for production deployment environment
2930
if (process.env.NODE_ENV === 'production') {
3031
config.plugins.push(
3132
new webpack.DefinePlugin({

0 commit comments

Comments
 (0)