react-battery-manager
v1.0.2
Published
Real-time BATTERY status tracking
Downloads
11
Maintainers
Readme
Overview :
Track battery status of device that opens the webpage.
How yo use :
import Battery from 'react-battery-manager';
//or: const Battery = require('react-battery-manager');
//Our default is Right to left.
<Battery />
//no required props
More Props :
import Battery from 'react-battery-manager';
<Battery
size={'xlarge'}
ltr={true} />
Manage colors by props :
- background .
- color .
- colorOnCharing .
- colorOnCritical .
Retrieve the current level of battery :
Use level
property to retrieve the current level of battery.
console.log(this.refs.myCompo.level);
<Battery ref="myCompo" />
or you can use onChange
prop for realtime tracking :
const batteryOnChange = (event) => console.log(event.currentTarget.level);
<Battery onChange={batteryOnChange} />