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';
|
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={this.props.createProject}
|
onClick={props.createProject}
|
||||||
>
|
>
|
||||||
New
|
New
|
||||||
</p>
|
</p>
|
||||||
|
@ -17,7 +16,7 @@ class Nav extends React.Component {
|
||||||
<li className="nav__item">
|
<li className="nav__item">
|
||||||
<p
|
<p
|
||||||
className="nav__save"
|
className="nav__save"
|
||||||
onClick={this.props.saveProject}
|
onClick={props.saveProject}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</p>
|
</p>
|
||||||
|
@ -25,13 +24,21 @@ class Nav extends React.Component {
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="nav__items-right">
|
<ul className="nav__items-right">
|
||||||
<li className="nav__item">
|
<li className="nav__item">
|
||||||
{this.props.user.authenticated && <p>Hello, {this.props.user.username}!</p>}
|
{props.user.authenticated && <p>Hello, {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><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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue