11import React , { useCallback , useRef } from 'react' ;
2- import MediaQuery from 'react-responsive' ;
2+ import { useMediaQuery } from 'react-responsive' ;
33import { useSelector } from 'react-redux' ;
44import { useHistory } from 'react-router-dom' ;
55import { useTranslation } from 'react-i18next' ;
@@ -9,8 +9,8 @@ import type { RootState } from '../../../reducers';
99import ExitIcon from '../../../images/exit.svg' ;
1010
1111type OverlayProps = {
12- children ?: React . ReactElement ;
13- actions ?: React . ReactElement ;
12+ children ?: React . ReactNode ;
13+ actions ?: React . ReactNode ;
1414 closeOverlay ?: ( ) => void ;
1515 title ?: string ;
1616 ariaLabel ?: string ;
@@ -35,6 +35,9 @@ export const Overlay = ({
3535
3636 const browserHistory = useHistory ( ) ;
3737
38+ const isDesktop = useMediaQuery ( { minWidth : 770 } ) ;
39+ const isMobile = useMediaQuery ( { maxWidth : 769 } ) ;
40+
3841 const close = useCallback ( ( ) => {
3942 const node = ref . current ;
4043 if ( ! node ) return ;
@@ -66,7 +69,7 @@ export const Overlay = ({
6669 < header className = "overlay__header" >
6770 < h2 className = "overlay__title" > { title } </ h2 >
6871 < div className = "overlay__actions" >
69- < MediaQuery minWidth = { 770 } > { actions } </ MediaQuery >
72+ { isDesktop && actions }
7073 < button
7174 className = "overlay__close-button"
7275 onClick = { close }
@@ -76,11 +79,9 @@ export const Overlay = ({
7679 </ button >
7780 </ div >
7881 </ header >
79- < MediaQuery maxWidth = { 769 } >
80- { actions && (
81- < div className = "overlay__actions-mobile" > { actions } </ div >
82- ) }
83- </ MediaQuery >
82+ { isMobile && actions && (
83+ < div className = "overlay__actions-mobile" > { actions } </ div >
84+ ) }
8485 { children }
8586 </ section >
8687 </ div >
0 commit comments