MCPcopy Create free account
hub / github.com/cloudflare/meet / ScreenshareButton

Function ScreenshareButton

app/components/ScreenshareButton.tsx:10–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8interface ScreenshareButtonProps {}
9
10export const ScreenshareButton: FC<ScreenshareButtonProps> = () => {
11 const {
12 userMedia: { startScreenShare, endScreenShare, screenShareEnabled },
13 } = useRoomContext()
14
15 const [canShareScreen, setCanShareScreen] = useState(true)
16
17 // setting this in a useEffect because we need to do this feature
18 // detection to remove it for iOS, but the feature detection also
19 // doesn't work on the server, so it causes a mismatch between
20 // the server/client that React doesn't like
21 useEffect(() => {
22 setCanShareScreen(
23 typeof navigator.mediaDevices !== 'undefined' &&
24 navigator.mediaDevices.getDisplayMedia !== undefined
25 )
26 }, [])
27
28 if (!canShareScreen) return null
29
30 return (
31 <Button
32 displayType={screenShareEnabled ? 'danger' : 'secondary'}
33 onClick={screenShareEnabled ? endScreenShare : startScreenShare}
34 >
35 <VisuallyHidden>Share screen</VisuallyHidden>
36 <Icon type="screenshare" />
37 </Button>
38 )
39}

Callers

nothing calls this directly

Calls 1

useRoomContextFunction · 0.90

Tested by

no test coverage detected