Skip to content

Commit

Permalink
added proptypes to each component that uses props
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwestbury committed Dec 5, 2017
1 parent fed2030 commit 8261f39
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"firebase": "^4.7.0",
"prop-types": "^15.6.0",
"re-base": "^3.2.0",
"react": "^16.1.1",
"react-addons-css-transition-group": "^15.6.2",
Expand Down
5 changes: 5 additions & 0 deletions src/components/AddFishForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';



Expand Down Expand Up @@ -37,4 +38,8 @@ class AddFishForm extends React.Component {
}
}

AddFishForm.propTypes = {
addFish: PropTypes.func.isRequired
};

export default AddFishForm;
7 changes: 7 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import Inventory from './Inventory';
import sampleFishes from '../sample-fishes';
import Fish from './Fish';
import base from '../base';
import PropTypes from 'prop-types';



class App extends React.Component {
constructor() {
Expand Down Expand Up @@ -116,4 +119,8 @@ class App extends React.Component {
}
}

App.propTypes = {
match: PropTypes.object.isRequired
};

export default App;
8 changes: 8 additions & 0 deletions src/components/Fish.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { formatPrice } from '../helpers';
import PropTypes from 'prop-types';



class Fish extends React.Component {
Expand All @@ -23,4 +25,10 @@ class Fish extends React.Component {
}
}

Fish.propTypes = {
details: PropTypes.object.isRequired,
index: PropTypes.string.isRequired,
addToOrder: PropTypes.func.isRequired,
};

export default Fish;
4 changes: 4 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';


const Header = (props) => {
Expand All @@ -17,6 +18,9 @@ const Header = (props) => {
)
}

Header.propTypes = {
tagline: PropTypes.string.isRequired
};



Expand Down
9 changes: 9 additions & 0 deletions src/components/Inventory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import AddFishForm from './AddFishForm';
import PropTypes from 'prop-types';

class Inventory extends React.Component {
constructor () {
Expand Down Expand Up @@ -47,4 +48,12 @@ class Inventory extends React.Component {
}
}

Inventory.propTypes = {
fishes: PropTypes.object.isRequired,
updateFish: PropTypes.func.isRequired,
removeFish: PropTypes.func.isRequired,
addFish: PropTypes.func.isRequired,
loadSamples: PropTypes.func.isRequired
};

export default Inventory;
7 changes: 7 additions & 0 deletions src/components/Order.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { formatPrice } from '../helpers';
import CSSTransitionGroup from 'react-addons-css-transition-group';
import PropTypes from 'prop-types';


class Order extends React.Component {
Expand Down Expand Up @@ -70,4 +71,10 @@ class Order extends React.Component {
}
}

Order.propTypes = {
fishes: PropTypes.object.isRequired,
order: PropTypes.object.isRequired,
removeFromOrder: PropTypes.func.isRequired
};

export default Order;
15 changes: 1 addition & 14 deletions src/components/StorePicker.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import React from 'react';
//getFunName is what's called a "named import".
//note that the two dots before /helpers is because the helpers.js file is two levels up in the file tree.
import {getFunName} from '../helpers.js';




class StorePicker extends React.Component {

goToStore(event){
console.log("You changed the URL");
//first: grab the text from the box

console.log(this.storeInput.value);
//second: transition from / to /store/:storeId
const storeId = this.storeInput.value;
this.props.history.push(`/store/${storeId}`)
//this.props.location
//this.props.match
// this.context.router.transitionTo(`/store/${storeId}`)

}

render() {
Expand All @@ -33,8 +22,6 @@ class StorePicker extends React.Component {
}
}

// StorePicker.contextTypes = {
// router: React.PropTypes.object
// }


export default StorePicker;

0 comments on commit 8261f39

Please sign in to comment.