-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#26] 워크스페이스 페이지의 불필요한 리렌더링 개선 #35
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4409ef
✨ feat: css 속성 물음표 아이콘 좌표를 전역 상태로 관리하는 것이 아닌 local 상태 변수를 통해 관리하도록 변경
lee0jae330 524a000
Revert "✨ feat: css 속성 물음표 아이콘 좌표를 전역 상태로 관리하는 것이 아닌 local 상태 변수를 통해 …
lee0jae330 be4ba9c
🔨 refactor: css속성 물음표 아이콘 좌표를 전역상태가 아닌 local 상태로 관리
lee0jae330 3f38806
🔨 refactor: 기존에 사용하던 매직넘버를 삭제하고 useLayoutEffect를 통해 툴팁의 높이를 직접 측정하고 툴…
lee0jae330 9630017
🔨 refactor: css item 물음표 아이콘 위치를 전역 상태가 아닌 로컬 상태변수로 관리하도록 변경, 불필요한 cs…
lee0jae330 c8599ec
🔨 refactor: useCssTooltip 훅을 통해 좌표 계산을 하도록 변경
lee0jae330 ee6098d
Merge branch 'refactor/26' of github.com:boostcampwm-2024/refactor-we…
lee0jae330 1466990
🙀 chore: 타입 단언 대신 타입 선언으로 변경경
lee0jae330 3d31790
🙀 chore: 불필요한 변수 및 반환값 삭제
lee0jae330 f7d9a4e
🙀 chore: 커스텀 select에서 사용하는 type 및 enum type 폴더로 분리
lee0jae330 30341a5
🔨 refactor: css 클래스 리스트를 만드는 로직을 커스텀 훅으로 분리
lee0jae330 07a64ef
🔨 refactor: useCssPropsStore에서 각 상태를 구조분해할당으로 사용하여 모든 상태를 구독하여 불필요한 리…
lee0jae330 df789f4
🎨 style: 불필요한 스타일 코드 삭제
lee0jae330 210d915
🙀 chore: 변경된 props 반영
lee0jae330 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 9 additions & 7 deletions
16
apps/client/src/entities/workspace/CssTooltip/CssTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { TOption } from '@/shared/types'; | ||
import { useClassBlockStore } from '@/shared/store'; | ||
|
||
export const useCssClassList = () => { | ||
const { classBlockList } = useClassBlockStore(); | ||
const [cssClassList, setCssClassList] = useState<string[]>([]); | ||
|
||
useEffect(() => { | ||
setCssClassList(classBlockList); | ||
}, [classBlockList]); | ||
|
||
const selectOptions: TOption[] = [ | ||
{ value: '', label: '클래스를 선택해주세요' }, | ||
...cssClassList.map((cssClass) => ({ | ||
value: cssClass, | ||
label: cssClass, | ||
})), | ||
]; | ||
|
||
return { selectOptions }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { useCssTooltipStore } from '@/shared/store'; | ||
import { useEffect } from 'react'; | ||
import { useWindowSize } from '@/shared/hooks'; | ||
import { useLayoutEffect, useRef, useState } from 'react'; | ||
|
||
export const useCssTooltip = () => { | ||
const { leftX, topY, offsetX, offsetY, setLeftX, setTopY } = useCssTooltipStore(); | ||
import { useWindowSize } from '@/shared/hooks'; | ||
|
||
const { screenWidth, screenHeight } = useWindowSize(); | ||
export const useCssTooltip = (leftX: number, topY: number) => { | ||
const tooltipRef = useRef<HTMLDivElement | null>(null); | ||
const [tooltipHeight, setTooltipHeight] = useState<number>(0); | ||
const { screenHeight } = useWindowSize(); | ||
|
||
useEffect(() => { | ||
const tooltipHeight = 40; | ||
setLeftX(offsetX); | ||
if (offsetY + tooltipHeight > screenHeight) { | ||
setTopY(-offsetY + tooltipHeight); // 높이를 벗어나는 것임 | ||
} else { | ||
setTopY(offsetY); | ||
useLayoutEffect(() => { | ||
if (tooltipRef.current) { | ||
setTooltipHeight(tooltipRef.current.getBoundingClientRect().height); | ||
} | ||
}, [offsetX, offsetY, screenWidth, screenHeight]); | ||
return () => setTooltipHeight(0); | ||
}, [tooltipRef.current]); | ||
|
||
let tooltipX = leftX; | ||
let tooltipY = 0; | ||
|
||
if (topY + tooltipHeight > screenHeight) { | ||
tooltipY = -topY + tooltipHeight; | ||
} else { | ||
tooltipY = topY; | ||
} | ||
|
||
return { leftX, topY }; | ||
return { tooltipX, tooltipY, tooltipRef }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum SelectSize { | ||
SMALL = 'SMALL', | ||
|
||
MEDIUM = 'MEDIUM', | ||
} | ||
|
||
export type TOption = { | ||
value: string; | ||
label: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구조분해할당을 지양하는 것이 베스트지만, 여러 상태를 불러와야할 경우 useShallow도 추천드립니당