Skip to content

Commit

Permalink
fix: memo card
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardocasares committed Nov 3, 2020
1 parent 5ba6f20 commit e33f795
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions src/components/Card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from "react";
import { FC, memo } from "react";
import { PlayCircle } from "@geist-ui/react-icons";
import { HeartToggle } from "@/components/Toggles";
import { Container, Cover, Button, Title, Subtitle, Body } from "./style";
Expand All @@ -15,29 +15,23 @@ export type Card = {
onUnFaved: (ev: React.MouseEvent) => void;
};

export const Card: FC<Card> = ({
hash,
title,
subtitle,
onPlay,
onFaved,
onUnFaved,
isFaved,
}) => (
<Container>
<Cover hash={hash}>
<Button onClick={onPlay}>
<PlayCircle size={64} />
</Button>
</Cover>
<Body>
<div style={{ display: "grid" }}>
<Title>{title}</Title>
<Subtitle>{subtitle || DEFAULT_SUBTITLE}</Subtitle>
</div>
<Button onClick={!isFaved ? onFaved : onUnFaved}>
<HeartToggle active={isFaved} />
</Button>
</Body>
</Container>
export const Card: FC<Card> = memo(
({ hash, title, subtitle, onPlay, onFaved, onUnFaved, isFaved }) => (
<Container>
<Cover hash={hash}>
<Button onClick={onPlay}>
<PlayCircle size={64} />
</Button>
</Cover>
<Body>
<div style={{ display: "grid" }}>
<Title>{title}</Title>
<Subtitle>{subtitle || DEFAULT_SUBTITLE}</Subtitle>
</div>
<Button onClick={!isFaved ? onFaved : onUnFaved}>
<HeartToggle active={isFaved} />
</Button>
</Body>
</Container>
)
);

0 comments on commit e33f795

Please sign in to comment.