uidotdev / usehooks

A collection of modern, server-safe React hooks – from the ui.dev team

Home Page:https://usehooks.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useBattery hook not working when run on local network

kriptonian1 opened this issue · 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