Skip to content

Commit c4ce02f

Browse files
Copilotluoxuhai
andcommitted
Handle unavailable battery level in example app
Co-authored-by: luoxuhai <37284154+luoxuhai@users.noreply.github.com>
1 parent 5a7fdc6 commit c4ce02f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎example/src/App.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export default function App() {
4444
<View style={styles.infoContainer}>
4545
<Text style={styles.label}>Battery Level:</Text>
4646
<Text style={styles.value}>
47-
{batteryLevel !== null ? `${batteryLevel.toFixed(0)}%` : 'Loading...'}
47+
{batteryLevel !== null
48+
? batteryLevel < 0
49+
? 'Unavailable'
50+
: `${batteryLevel.toFixed(0)}%`
51+
: 'Loading...'}
4852
</Text>
4953
</View>
5054

0 commit comments

Comments
 (0)