Skip to content

Commit d8f493b

Browse files
author
DESKTOP-J99B7TH\Gilbert
committed
Add non compliant examples in md
1 parent c62646f commit d8f493b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

eslint-plugin/docs/rules/avoid-keep-awake.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@
77
## Why is this an issue?
88

99
To avoid draining the battery, an Android device that is left idle quickly falls asleep.
10-
Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically use the FLAG_KEEP_SCREEN_ON in their activity. Another way to implement this is in their application's layout XML file, by using the android:keepScreenOn attribute.
10+
Hence, keeping the screen on should be avoided, unless it is absolutely necessary.
11+
12+
```js
13+
export default function KeepAwakeExample() {
14+
useKeepAwake(); // Non compliant
15+
return (
16+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
17+
<Text>This screen will never sleep!</Text>
18+
</View>
19+
);
20+
}
21+
```
22+
23+
```js
24+
_activate = () => {
25+
activateKeepAwake(); // Non-compliant
26+
alert('Activated!');
27+
};
28+
```
1129

1230
## Resources
1331

0 commit comments

Comments
 (0)