Skip to content

Commit

Permalink
use stateless component syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
echenley committed Nov 1, 2015
1 parent 560bc05 commit 6e5352d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 46 deletions.
22 changes: 9 additions & 13 deletions src/js/components/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

import React, { PropTypes } from 'react';

const Icon = React.createClass({
propTypes: {
svg: PropTypes.string.isRequired
},
const Icon = (props) => (
<i { ...props }
svg={ null }
dangerouslySetInnerHTML={ { __html: props.svg } }>
</i>
);

render() {
return (
<i { ...this.props }
svg={ null }
dangerouslySetInnerHTML={ { __html: this.props.svg } }>
</i>
);
}
});
Icon.propTypes = {
svg: PropTypes.string.isRequired
};

export default Icon;
29 changes: 11 additions & 18 deletions src/js/components/PostLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@
import React, { PropTypes } from 'react';
import hostNameFromUrl from '../util/hostNameFromUrl';

const PostLink = React.createClass({
const PostLink = ({ url, title }) => (
<div className="post-link">
<a className="post-title" href={ url }>{ title }</a>
<span className="hostname">
(<a href={ url }>{ hostNameFromUrl(url) }</a>)
</span>
</div>
);

propTypes: {
post: PropTypes.object
},

render() {
const { url, title } = this.props.post;

return (
<div className="post-link">
<a className="post-title" href={ url }>{ title }</a>
<span className="hostname">
(<a href={ url }>{ hostNameFromUrl(url) }</a>)
</span>
</div>
);
}
});
PostLink.PropTypes = {
post: PropTypes.object
};

export default PostLink;
28 changes: 13 additions & 15 deletions src/js/components/ProfileLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
import React, { PropTypes } from 'react';
import Link from 'react-router/lib/Link';

const ProfileLink = React.createClass({
propTypes: {
user: PropTypes.object
},
const ProfileLink = (props) => {
const { username, md5hash } = props.user;
const gravatarURI = 'http://www.gravatar.com/avatar/' + md5hash + '?d=mm';

render() {
const { username, md5hash } = this.props.user;
const gravatarURI = 'http://www.gravatar.com/avatar/' + md5hash + '?d=mm';
return (
<Link to={ `/user/${username}` } className="profile-link">
<span className="username">{ username }</span>
<img src={ gravatarURI } className="profile-pic" />
</Link>
);
};

return (
<Link to={ `/user/${username}` } className="profile-link">
<span className="username">{ username }</span>
<img src={ gravatarURI } className="profile-pic" />
</Link>
);
}
});
ProfileLink.propTypes = {
user: PropTypes.object
};

export default ProfileLink;

0 comments on commit 6e5352d

Please sign in to comment.