Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Don't let LikeTagButton pass reduntant props to IconComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Sep 19, 2016
1 parent 6f4a631 commit 6513a42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/components/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ const IconComponent = ({
classnameIcon.push(`micon-rotate`);
}

const divProps = { ...props };
delete divProps.is_logged_in;
delete divProps.liked_tags;
delete divProps.tag;
delete divProps.triggers;

return (
<div
{...divProps}
{...props}
disabled={disabled}
onClick={localOnClick}
className={classnameIcon.join(' ')}
Expand Down
24 changes: 22 additions & 2 deletions src/components/like-tag-button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
/*
This file is a part of libertysoil.org website
Copyright (C) 2016 Loki Education (Social Enterprise)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropTypes } from 'react';
import ga from 'react-google-analytics';
import { omit } from 'lodash';

import Icon from './icon';

Expand All @@ -12,8 +30,8 @@ export default class LikeTagButton extends React.Component {
static propTypes = {
hashtag: PropTypes.string,
is_logged_in: PropTypes.bool.isRequired,
// {tagName: tag}
liked_tags: PropTypes.shape({}),
tag: PropTypes.string,
triggers: PropTypes.shape({
likeTag: PropTypes.func.isRequired,
unlikeTag: PropTypes.func.isRequired
Expand Down Expand Up @@ -56,9 +74,11 @@ export default class LikeTagButton extends React.Component {
color = false;
}

const iconProps = omit(props, Object.keys(LikeTagButton.propTypes));

return (
<Icon
{...props}
{...iconProps}
className={`action ${className}`}
onClick={this._toggleLike}
icon={icon}
Expand Down

0 comments on commit 6513a42

Please sign in to comment.