|
1 | | -import React from 'react'; |
2 | | -import { LikeHeart } from 'app/pages/common/LikeHeart'; |
3 | 1 | import { Sandbox } from '@codesandbox/common/lib/types'; |
4 | | -import { observer } from 'app/componentConnectors'; |
5 | | - |
6 | | -import { ForkIcon } from './ForkIcon'; |
7 | | -import { EyeIcon } from './EyeIcon'; |
| 2 | +import { useOvermind } from 'app/overmind'; |
| 3 | +import { LikeHeart } from 'app/pages/common/LikeHeart'; |
| 4 | +import React from 'react'; |
8 | 5 |
|
9 | 6 | import { Stats as StatsWrapper } from './elements'; |
| 7 | +import { EyeIcon } from './EyeIcon'; |
| 8 | +import { ForkIcon } from './ForkIcon'; |
10 | 9 | import { Stat } from './Stat'; |
11 | 10 |
|
12 | 11 | interface Props { |
13 | 12 | sandbox: Sandbox; |
14 | 13 | } |
15 | 14 |
|
16 | | -const StatsComponent = ({ sandbox }: Props) => ( |
17 | | - <StatsWrapper> |
18 | | - <Stat |
19 | | - Icon={<LikeHeart sandbox={sandbox} colorless />} |
20 | | - count={sandbox.likeCount} |
21 | | - /> |
| 15 | +const StatsComponent: React.FC<Props> = ({ sandbox }) => { |
| 16 | + // We want to observe the sandbox |
| 17 | + useOvermind(); |
| 18 | + |
| 19 | + return ( |
| 20 | + <StatsWrapper> |
| 21 | + <Stat |
| 22 | + Icon={<LikeHeart sandbox={sandbox} colorless />} |
| 23 | + count={sandbox.likeCount} |
| 24 | + /> |
22 | 25 |
|
23 | | - <Stat Icon={<EyeIcon />} count={sandbox.viewCount} /> |
| 26 | + <Stat Icon={<EyeIcon />} count={sandbox.viewCount} /> |
24 | 27 |
|
25 | | - <Stat Icon={<ForkIcon />} count={sandbox.forkCount} /> |
26 | | - </StatsWrapper> |
27 | | -); |
| 28 | + <Stat Icon={<ForkIcon />} count={sandbox.forkCount} /> |
| 29 | + </StatsWrapper> |
| 30 | + ); |
| 31 | +}; |
28 | 32 |
|
29 | | -export const Stats = observer(StatsComponent); |
| 33 | +export const Stats = StatsComponent; |
0 commit comments