add proptypes to nav, fix proptypes for login
This commit is contained in:
parent
3ab89b4cae
commit
684646c785
3 changed files with 45 additions and 34 deletions
|
@ -1,15 +1,14 @@
|
|||
import React from 'react';
|
||||
import React, { PropTypes } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
class Nav extends React.Component {
|
||||
render() {
|
||||
function Nav(props) {
|
||||
return (
|
||||
<nav className="nav">
|
||||
<ul className="nav__items-left">
|
||||
<li className="nav__item">
|
||||
<p
|
||||
className="nav__new"
|
||||
onClick={this.props.createProject}
|
||||
onClick={props.createProject}
|
||||
>
|
||||
New
|
||||
</p>
|
||||
|
@ -17,7 +16,7 @@ class Nav extends React.Component {
|
|||
<li className="nav__item">
|
||||
<p
|
||||
className="nav__save"
|
||||
onClick={this.props.saveProject}
|
||||
onClick={props.saveProject}
|
||||
>
|
||||
Save
|
||||
</p>
|
||||
|
@ -25,13 +24,21 @@ class Nav extends React.Component {
|
|||
</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>}
|
||||
{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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue