usehooks icon indicating copy to clipboard operation
usehooks copied to clipboard

useBattery hook not working when run on local network

Open kriptonian1 opened this issue 1 year ago • 0 comments

useBattery hook is throwing null for everything, when I am using running the nextjs app with local net workwork npm run dev -- -H <ip_from_ifconfig>

Code

import { useBattery } from "@uidotdev/usehooks";
import React from "react";
// import { AnimatePresence, motion } from "framer-motion";

function Battery(): React.JSX.Element {
  const { loading, level, charging, chargingTime, dischargingTime } =
    useBattery();
  const percentage: number = level !== null ? Math.floor(level * 100) : 100;

  console.log(
    `Battery: ${percentage}% level: ${level} charging: ${charging} chargingTime: ${chargingTime} dischargingTime: ${dischargingTime} loading: ${loading}`,
  );
.....

Logs

image

kriptonian1 avatar May 02 '24 06:05 kriptonian1