Skip to content

Commit

Permalink
refactor: 조건부 렌더링을 props 전달 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongWon-CHO committed Oct 15, 2024
1 parent 7cc0159 commit 78f9e6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/layout/Header/MobileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ import { useLogout } from 'query/auth';

import styles from './Dropdown.module.scss';

function MobileDropdown() {
interface MobileDropdownProps {
view: boolean;
}

function MobileDropdown({ view }: MobileDropdownProps) {
const { logout } = useLogout();

const handleLogout = () => {
logout();
};

return (
<div className={styles.container}>
<Link className={styles['setting-item__link']} to="https://forms.gle/wqD6PkjZoaaHJ1bo8" target="_blank" rel="noopener noreferrer">
<div className={styles['setting-item__word']}>BCSD Lab에 문의하기</div>
</Link>
<button type="button" className={styles['setting-item__button']} onClick={handleLogout}>
<div className={styles['setting-item__warning']}>로그아웃</div>
</button>
<div>
{view && (
<div className={styles.container}>
<Link className={styles['setting-item__link']} to="https://forms.gle/wqD6PkjZoaaHJ1bo8" target="_blank" rel="noopener noreferrer">
<div className={styles['setting-item__word']}>BCSD Lab에 문의하기</div>
</Link>
<button type="button" className={styles['setting-item__button']} onClick={handleLogout}>
<div className={styles['setting-item__warning']}>로그아웃</div>
</button>
</div>
)}
</div>
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/layout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ function Header() {
>
<Menu className={styles.menu} />
</button>
{view && <MobileDropdown />}
<MobileDropdown view={view} />
</div>
</ul>

<Link to="/setting" />
</div>
) : (
Expand Down

0 comments on commit 78f9e6a

Please sign in to comment.