mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added tag searching router
This commit is contained in:
parent
4da04bb970
commit
f2289f4530
5 changed files with 80 additions and 0 deletions
28
src/containers/sidebars/SidebarWrapper/index.tsx
Normal file
28
src/containers/sidebars/SidebarWrapper/index.tsx
Normal file
|
@ -0,0 +1,28 @@
|
|||
import React, { FC, useEffect, useRef } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
||||
|
||||
interface IProps {}
|
||||
|
||||
const SidebarWrapper: FC<IProps> = ({ children }) => {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return;
|
||||
disableBodyScroll(ref.current);
|
||||
|
||||
return () => enableBodyScroll(ref.current);
|
||||
}, [ref.current]);
|
||||
|
||||
return createPortal(
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.content} ref={ref}>
|
||||
{children}
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
);
|
||||
};
|
||||
|
||||
export { SidebarWrapper };
|
Loading…
Add table
Add a link
Reference in a new issue