Skip to content

Commit

Permalink
feat: useBodyScrollLock 훅 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn2468 committed Feb 3, 2024
1 parent 6b76701 commit 41ab6c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/admin/src/components/SettlementDialogContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { bankItems } from '~/constants/bankItems';

import Styled from './SettlementDialogContent.styles';
import { useState } from 'react';
import { useBodyScrollLock } from '~/hooks/useBodyScrollLock';

const titles = [
'은행을 선택해 주세요.',
Expand All @@ -23,6 +24,9 @@ const SettlementDialogContent = ({ onClose }: Props) => {
const [accountHolder, setAccountHolder] = useState<string>('');
const [accountHolderError, setAccountHolderError] = useState<string | undefined>(undefined);
const [accountNumberError, setAccountNumberError] = useState<string | undefined>(undefined);

useBodyScrollLock();

return (
<Styled.Container>
<Styled.Title>{titles[currentStepIndex]}</Styled.Title>
Expand Down
11 changes: 11 additions & 0 deletions apps/admin/src/hooks/useBodyScrollLock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useLayoutEffect } from 'react';

export const useBodyScrollLock = () => {
useLayoutEffect(() => {
const originalStyle = window.getComputedStyle(document.body).overflow;
document.body.style.overflow = 'hidden';
return () => {
document.body.style.overflow = originalStyle;
};
}, []);
};

0 comments on commit 41ab6c7

Please sign in to comment.