Skip to content

Commit eb6baf7

Browse files
christianalfoniSaraVieira
authored andcommitted
StatsComponent: refactor to overmind (codesandbox#3182)
1 parent facdefc commit eb6baf7

File tree

1 file changed

+21
-17
lines changed
  • packages/app/src/app/pages/common/Stats

1 file changed

+21
-17
lines changed
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
import React from 'react';
2-
import { LikeHeart } from 'app/pages/common/LikeHeart';
31
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';
85

96
import { Stats as StatsWrapper } from './elements';
7+
import { EyeIcon } from './EyeIcon';
8+
import { ForkIcon } from './ForkIcon';
109
import { Stat } from './Stat';
1110

1211
interface Props {
1312
sandbox: Sandbox;
1413
}
1514

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+
/>
2225

23-
<Stat Icon={<EyeIcon />} count={sandbox.viewCount} />
26+
<Stat Icon={<EyeIcon />} count={sandbox.viewCount} />
2427

25-
<Stat Icon={<ForkIcon />} count={sandbox.forkCount} />
26-
</StatsWrapper>
27-
);
28+
<Stat Icon={<ForkIcon />} count={sandbox.forkCount} />
29+
</StatsWrapper>
30+
);
31+
};
2832

29-
export const Stats = observer(StatsComponent);
33+
export const Stats = StatsComponent;

0 commit comments

Comments
 (0)