Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const Sidebar: SFC = () => {
const [hidden, setHidden] = useState(true)
const [query, setQuery] = useState('')
const menus = useMenus({ query })
const windowSize = useWindowSize()
const isDesktop = windowSize.innerWidth >= breakpoints.desktop
const prevIsDesktop = usePrevious(isDesktop)
useEffect(() => {
if (!hidden && !prevIsDesktop && isDesktop) {
setHidden(true)
document.documentElement!.classList.remove('with-overlay')
}
})
const addOverlayClass = (isHidden: boolean) => {
const method = !isHidden ? 'add' : 'remove'
if (typeof window !== 'undefined' && !isDesktop) {
document.documentElement!.classList[method]('with-overlay')
}