Skip to content

Commit

Permalink
Merge pull request #5 from dragonsuperf/dev
Browse files Browse the repository at this point in the history
chartsection의 useeffect 리팩터링
  • Loading branch information
dragonsuperf authored Apr 4, 2021
2 parents aeab221 + 49a71db commit 9490c90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
26 changes: 15 additions & 11 deletions src/components/chart/ChartSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ function ChartSection() {
}, [sidebarState.selectedCoin]);

useEffect(() => {
getTickDataFromMessage();
}, [lastMessage]);

useEffect(() => {
switch (readyState) {
case ReadyState.OPEN:
sendMessage(SOCKET_API_SUB);
break;
default:
break;
}
}, [readyState]);

const getTickDataFromMessage = () => {
if (lastMessage !== null) {
const data = JSON.parse(lastMessage.data).content;
if (data !== null && data !== undefined) {
Expand Down Expand Up @@ -77,17 +91,7 @@ function ChartSection() {
setRealtimeTickDatas(newRealTimeTickDatas);
}
}
}, [lastMessage]);

useEffect(() => {
switch (readyState) {
case ReadyState.OPEN:
sendMessage(SOCKET_API_SUB);
break;
default:
break;
}
}, [readyState]);
};

const convertDataToTickPrice = (datas: any): TickData[] => {
return datas.map((data: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const GlobalStyle = createGlobalStyle`
}
@font-face {
font-family: 'NanumSquareBold';
font-family: 'NanumSquare';
font-weight: 700;
src: url('/fonts/NanumSquareRoundB.ttf') format('truetype');
}
@font-face {
font-family: 'NanumSquareExtraBold';
font-family: 'NanumSquare';
font-weight: 800;
src: url('/fonts/NanumSquareRoundEB.ttf') format('truetype');
}
Expand Down

0 comments on commit 9490c90

Please sign in to comment.