Skip to content
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

feature/FE-052 : IconButton disabled 에러 수정 #71

Merged
merged 2 commits into from
Jul 4, 2023
Merged

Conversation

naro-Kim
Copy link
Contributor

@naro-Kim naro-Kim commented Jul 3, 2023

체크 리스트

  • 적절한 제목으로 수정했나요?
  • 관련된 이슈와 연결 시켰나요?
  • Target Branch를 올바르게 설정했나요?
  • Label을 알맞게 설정했나요?

작업 내역

  • IconButton useEffect 관련으로 disabled가 미적용되는 문제 해결

문제 상황과 해결

  • disabled 상태를 캐치해주지 못해 2개의 useEffect로 분리했습니다.

이전 코드

  useEffect(() => {
    if (!error) return;
    setStatus(error ? ICON_STATUS.ERROR : disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
  }, [error, disabled]);

변경된 코드

  useEffect(() => {
    if (!error) return;
    setStatus(error ? ICON_STATUS.ERROR : ICON_STATUS.DEFAULT);
  }, [error, disabled]);

  useEffect(() => {
  // disabled의 경우, return문이 존재하면 default로 상태 복원이 되지않아 return문을 사용하지 않았습니다.
    setStatus(disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
  }, [disabled]);
  • 다만 '-' 버튼 hover시 svg와 id가 제대로 변경되고 있음에도 hover 아이콘이 렌더링되지 않는것으로 보입니다
2.mov

비고

Comment on lines 43 to +51
useEffect(() => {
if (!error) return;
setStatus(error ? ICON_STATUS.ERROR : disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
setStatus(error ? ICON_STATUS.ERROR : ICON_STATUS.DEFAULT);
}, [error, disabled]);

useEffect(() => {
setStatus(disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
}, [disabled]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IconButton 내에서 useEffect 가 많아져서 로직 파악이 어려워지고 있는 것 같아요..!
나중에 기회될때 useEffect 를 없애는 방향으로 리팩토링 진행해보면 좋을 것 같아요~ stateprops에 변화에 대응하기 위해 useEffect를 사용하는 것은 좋지 않은 패턴이라고 하네요,,!

Comment on lines +9 to +13
return (
<svg width={width} height={height} fill={fill} {...rest}>
<use href={`/sprite.svg#${id}`} />
</svg>
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마이너스 아이콘이 호버 효과가 반영 안되는 문제가 있어보이는데 확인해보니 minus-hover.svg 아이콘이 잘못된 것으로 보입니다! 하는 김에 수정해주시고 sprite.svg에도 반영해주시면 감사하겠습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 파일이 잘못되었나 싶어서 re-export한다음 피그마에 띄워 이상이 없는걸 확인해보고 sprite 생성을 했었는데.. 온전히 다 삭제하고 한번 다시 봐보겠습니다~!

@sonarcloud
Copy link

sonarcloud bot commented Jul 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@sxungchxn sxungchxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@naro-Kim naro-Kim merged commit 6ee51c4 into dev Jul 4, 2023
3 checks passed
@naro-Kim naro-Kim deleted the feature/FE-052 branch July 4, 2023 10:26
@naro-Kim naro-Kim self-assigned this Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants