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';
class Nav extends React.Component {
render() {
return (
<nav className="nav">
<ul className="nav__items-left">
<li className="nav__item">
<p
className="nav__new"
onClick={this.props.createProject}
>
New
</p>
</li>
<li className="nav__item">
<p
className="nav__save"
onClick={this.props.saveProject}
>
Save
</p>
</li>
</ul>
<ul className="nav__items-right">
<li className="nav__item">
{this.props.user.authenticated && <p>Hello, {this.props.user.username}!</p>}
{!this.props.user.authenticated && <p><Link to="/login">Login</Link> or <Link to="/signup">Sign Up</Link></p>}
</li>
</ul>
</nav>
);
}
function Nav(props) {
return (
<nav className="nav">
<ul className="nav__items-left">
<li className="nav__item">
<p
className="nav__new"
onClick={props.createProject}
>
New
</p>
</li>
<li className="nav__item">
<p
className="nav__save"
onClick={props.saveProject}
>
Save
</p>
</li>
</ul>
<ul className="nav__items-right">
<li className="nav__item">
{props.user.authenticated && <p>Hello, {props.user.username}!</p>}
{!props.user.authenticated && <p><Link to="/login">Login</Link> or <Link to="/signup">Sign Up</Link></p>}
</li>
</ul>
</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;

View file

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

View file

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