Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/components/FullScreenButton.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useState } from 'react';
import { useContext, useMemo, useState } from 'react';
Comment thread
cbeer marked this conversation as resolved.
Resolved
import FullscreenIcon from '@mui/icons-material/FullscreenSharp';
import FullscreenExitIcon from '@mui/icons-material/FullscreenExitSharp';
import PropTypes from 'prop-types';
Expand All @@ -13,12 +13,10 @@ export function FullScreenButton({ className = undefined }) {
const handle = useContext(FullScreenContext);

// iPhone Safari does not support full screen on divs,
// Don't render the button if not supported
const [canFullscreenDiv, setCanFullscreenDiv] = useState(false);

useEffect(() => {
// Don't render the button if not supporte
const canFullscreenDiv = useMemo(() => {
const div = document.createElement('div');
setCanFullscreenDiv(typeof div.requestFullscreen === 'function');
return typeof div.requestFullscreen === 'function';
}, []);

if (!canFullscreenDiv) return null;
Expand Down
Loading