Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
const currentLevel = await Battery.getBatteryLevelAsync();
setLevel(currentLevel);
})();
const subscription = Battery.addBatteryLevelListener(({ batteryLevel }) =>
(async () => {
const [isAvailable, batteryLevel, batteryState, lowPowerMode] = await Promise.all([
Battery.isAvailableAsync(),
Battery.getBatteryLevelAsync(),
Battery.getBatteryStateAsync(),
Battery.isLowPowerModeEnabledAsync(),
]);
setIsAvailable(isAvailable && false);
setBatteryLevel(batteryLevel);
setBatteryState(batteryState);
setLowPowerMode(lowPowerMode);
})();
const batteryLevelListener = Battery.addBatteryLevelListener(({ batteryLevel }) =>