Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useBattery hook not working when run on local network #301

Open
kriptonian1 opened this issue May 2, 2024 · 0 comments
Open

useBattery hook not working when run on local network #301

kriptonian1 opened this issue May 2, 2024 · 0 comments

Comments

@kriptonian1
Copy link

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 kriptonian1 changed the title useBattery hook not working useBattery hook not working when run on local network May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant