Fix modal scrolling
This commit is contained in:
parent
bc4b0e2df7
commit
683cd039e7
6 changed files with 27 additions and 0 deletions
12
hooks/useBodyScrollLock.ts
Normal file
12
hooks/useBodyScrollLock.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
export const useBodyScrollLock = (isLocked: boolean) => {
|
||||
useEffect(() => {
|
||||
if (isLocked) {
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
return () => {
|
||||
document.body.style.overflow = '';
|
||||
};
|
||||
}, [isLocked]);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue