Stop scrolling on modal (#39)
Co-authored-by: Szymon Szlachtowicz <szymon.szlachtowicz@Szymons-MacBook-Pro.local>
This commit is contained in:
parent
3cd6d60188
commit
371864a4f1
|
@ -1,4 +1,4 @@
|
|||
import React, { ReactNode } from 'react'
|
||||
import React, { ReactNode, useEffect } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import { Colors } from '../constants/styles'
|
||||
import closeIcon from '../assets/images/close.svg'
|
||||
|
@ -10,6 +10,12 @@ type ModalProps = {
|
|||
}
|
||||
|
||||
export function Modal({ heading, children, setShowModal }: ModalProps) {
|
||||
useEffect(() => {
|
||||
document.body.style.overflow = 'hidden'
|
||||
return () => {
|
||||
document.body.style.overflow = 'unset'
|
||||
}
|
||||
}, [])
|
||||
return (
|
||||
<PopUpOverlay onClick={() => setShowModal(false)}>
|
||||
<PopUpWindow onClick={(e) => e.stopPropagation()}>
|
||||
|
|
Loading…
Reference in New Issue