battery-status-hook
v1.0.2
Published
Custom React Hook for Battery Status API
Downloads
5
Maintainers
Readme
React Hook for the Battery Status API
A react hook to get battery status
Install
npm install --save use-battery-hook
Usage
import React from 'react'
import { useBatteryStatus } from 'battery-status-hook'
const Battery = (): ReactElement => {
let battery = useBatteryStatus();
return (
battery.isSupported ?
<h1> Current Battery Level {level * 100}% </h1>
: <h1>Battery Status API not supported in this browser</h1>
)
}
License
MIT © NatesCode