···1+import {useId} from 'react'
2+import {useKeepAwake} from 'expo-keep-awake'
3+import {useIsFocused} from '@react-navigation/native'
4+5+/**
6+ * Stops the screen from sleeping. Only applies to the current screen.
7+ *
8+ * Note: Expo keeps the screen permanently awake when in dev mode, so
9+ * you'll only see this do anything when in production.
10+ *
11+ * @platform ios, android
12+ */
13+export function KeepAwake({enabled = true}) {
14+ const isFocused = useIsFocused()
15+ if (enabled && isFocused) {
16+ return <KeepAwakeInner />
17+ } else {
18+ return null
19+ }
20+}
21+22+function KeepAwakeInner() {
23+ const id = useId()
24+ // if you don't pass an explicit ID, any `useKeepAwake` hook unmounting disables them all.
25+ // very strange behaviour, but easily fixed by passing a unique ID -sfn
26+ useKeepAwake(id)
27+ return null
28+}
+3
src/components/KeepAwake.web.tsx
···000
···1+export function KeepAwake() {
2+ return null
3+}
+2
src/screens/VideoFeed/index.tsx
···93import {Check_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Check'
94import {EyeSlash_Stroke2_Corner0_Rounded as Eye} from '#/components/icons/EyeSlash'
95import {Leaf_Stroke2_Corner0_Rounded as LeafIcon} from '#/components/icons/Leaf'
096import * as Layout from '#/components/Layout'
97import {Link} from '#/components/Link'
98import {ListFooter} from '#/components/Lists'
···150 return (
151 <ThemeProvider theme="dark">
152 <Layout.Screen noInsetTop style={{backgroundColor: 'black'}}>
0153 <SystemBars style={{statusBar: 'light', navigationBar: 'light'}} />
154 <View
155 style={[
···93import {Check_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Check'
94import {EyeSlash_Stroke2_Corner0_Rounded as Eye} from '#/components/icons/EyeSlash'
95import {Leaf_Stroke2_Corner0_Rounded as LeafIcon} from '#/components/icons/Leaf'
96+import {KeepAwake} from '#/components/KeepAwake'
97import * as Layout from '#/components/Layout'
98import {Link} from '#/components/Link'
99import {ListFooter} from '#/components/Lists'
···151 return (
152 <ThemeProvider theme="dark">
153 <Layout.Screen noInsetTop style={{backgroundColor: 'black'}}>
154+ <KeepAwake />
155 <SystemBars style={{statusBar: 'light', navigationBar: 'light'}} />
156 <View
157 style={[