forked from corbt/react-native-keep-awake
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathindex.native.js
More file actions
27 lines (21 loc) · 526 Bytes
/
Copy pathindex.native.js
File metadata and controls
27 lines (21 loc) · 526 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React, { useEffect } from "react";
import ReactNativeKCKeepAwake from "./NativeKCKeepAwake";
export const activateKeepAwake = () => {
ReactNativeKCKeepAwake.activate();
};
export const deactivateKeepAwake = () => {
ReactNativeKCKeepAwake.deactivate();
};
export const useKeepAwake = () => {
useEffect(() => {
activateKeepAwake();
return deactivateKeepAwake;
}, []);
};
export default () => {
useEffect(() => {
activateKeepAwake();
return deactivateKeepAwake;
}, []);
return null;
};