add proptypes to nav, fix proptypes for login

This commit is contained in:
catarak 2016-06-27 16:14:26 -04:00
parent 3ab89b4cae
commit 684646c785
3 changed files with 45 additions and 34 deletions

View file

@ -1,37 +1,44 @@
import React from 'react'; import React, { PropTypes } from 'react';
import { Link } from 'react-router'; import { Link } from 'react-router';
class Nav extends React.Component { function Nav(props) {
render() { return (
return ( <nav className="nav">
<nav className="nav"> <ul className="nav__items-left">
<ul className="nav__items-left"> <li className="nav__item">
<li className="nav__item"> <p
<p className="nav__new"
className="nav__new" onClick={props.createProject}
onClick={this.props.createProject} >
> New
New </p>
</p> </li>
</li> <li className="nav__item">
<li className="nav__item"> <p
<p className="nav__save"
className="nav__save" onClick={props.saveProject}
onClick={this.props.saveProject} >
> Save
Save </p>
</p> </li>
</li> </ul>
</ul> <ul className="nav__items-right">
<ul className="nav__items-right"> <li className="nav__item">
<li className="nav__item"> {props.user.authenticated && <p>Hello, {props.user.username}!</p>}
{this.props.user.authenticated && <p>Hello, {this.props.user.username}!</p>} {!props.user.authenticated && <p><Link to="/login">Login</Link> or <Link to="/signup">Sign Up</Link></p>}
{!this.props.user.authenticated && <p><Link to="/login">Login</Link> or <Link to="/signup">Sign Up</Link></p>} </li>
</li> </ul>
</ul> </nav>
</nav> );
);
}
} }
Nav.propTypes = {
createProject: PropTypes.func.isRequired,
saveProject: PropTypes.func.isRequired,
user: PropTypes.shape({
authenticated: PropTypes.bool.isRequired,
username: PropTypes.string
}).isRequired
};
export default Nav; export default Nav;

View file

@ -1,4 +1,4 @@
import React from 'react'; import React, { PropTypes } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import DevTools from './components/DevTools'; import DevTools from './components/DevTools';
@ -22,4 +22,8 @@ class App extends React.Component {
} }
} }
App.propTypes = {
children: PropTypes.object
};
export default connect()(App); export default connect()(App);

View file

@ -31,7 +31,7 @@ function LoginForm(props) {
LoginForm.propTypes = { LoginForm.propTypes = {
fields: PropTypes.shape({ fields: PropTypes.shape({
username: PropTypes.string.isRequired, email: PropTypes.string.isRequired,
password: PropTypes.string.isRequired password: PropTypes.string.isRequired
}).isRequired, }).isRequired,
handleSubmit: PropTypes.func.isRequired, handleSubmit: PropTypes.func.isRequired,