@@ -18,12 +18,15 @@ interface FullscreenProps {
1818 className ?: string ;
1919}
2020
21- const fullscreenRoot = document . getElementById ( 'fullscreen-root' ) ?? undefined ;
22-
23- function Fullscreen ( { children, className} : FullscreenProps ) {
21+ export function Fullscreen ( { children, className} : FullscreenProps ) {
2422 const isFullscreen = useTypedSelector ( ( state ) => state . fullscreen ) ;
2523 const dispatch = useTypedDispatch ( ) ;
2624
25+ const fullscreenRoot = React . useMemo (
26+ ( ) => document . getElementById ( 'fullscreen-root' ) ?? undefined ,
27+ [ ] ,
28+ ) ;
29+
2730 const onDisableFullScreen = React . useCallback ( ( ) => {
2831 dispatch ( disableFullscreen ( ) ) ;
2932 } , [ dispatch ] ) ;
@@ -51,7 +54,7 @@ function Fullscreen({children, className}: FullscreenProps) {
5154 setContainer ( null ) ;
5255 div . remove ( ) ;
5356 } ;
54- } , [ ] ) ;
57+ } , [ fullscreenRoot ] ) ;
5558
5659 const ref = React . useRef < HTMLDivElement > ( null ) ;
5760 React . useLayoutEffect ( ( ) => {
@@ -62,7 +65,7 @@ function Fullscreen({children, className}: FullscreenProps) {
6265 ref . current ?. appendChild ( container ) ;
6366 }
6467 }
65- } , [ container , isFullscreen ] ) ;
68+ } , [ container , fullscreenRoot , isFullscreen ] ) ;
6669
6770 if ( ! container ) {
6871 return null ;
@@ -85,5 +88,3 @@ function Fullscreen({children, className}: FullscreenProps) {
8588 </ div >
8689 ) ;
8790}
88-
89- export default Fullscreen ;
0 commit comments