Skip to content

useBattery hook not working when run on local network #301

Open
@kriptonian1

Description

@kriptonian1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions