Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
el.getBoundingClientRect is not a function in react odometer js with react visibility sensor?

I am trying to use react-odometer js with react-visibility-sensor in next js. Here I am getting one err like the image? How can I get rid of this error, Experts please help. enter image description here

Here is my code https://codesandbox.io/s/summer-dream-ysi00

import { useState, useEffect } from "react";
import dynamic from "next/dynamic";
import "odometer/themes/odometer-theme-default.css";
const Odometer = dynamic(import("react-odometerjs"), {
  ssr: false,
  loading: () => 0
});
import VisibilitySensor from "react-visibility-sensor";

export default function IndexPage() {
  const [odometerValue, setOdometerValue] = useState(0);
  const [view, setView] = useState(false);
  const onVisibilityChange = (isVisible) => {
    if (isVisible) {
      setView(true);
    }
  };
  useEffect(() => {
    setTimeout(() => {
      setOdometerValue(500);
    }, 10);
  }, []);
  return (
    <VisibilitySensor onChange={onVisibilityChange} offset={8} delayedCall>
      <Odometer
        value={view ? odometerValue : 0}
        format="(,ddd)"
        theme="default"
      />
    </VisibilitySensor>
  );
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

wrap Odometer in a div, like so

<VisibilitySensor onChange={onVisibilityChange} offset={8} delayedCall>
  <div>
    <Odometer
      value={view ? odometerValue : 0}
      format="(,ddd)"
      theme="default"
    />
  </div>
</VisibilitySensor>;

you should see '500' rendered.

https://codesandbox.io/s/wonderful-fast-y3k4s?file=/pages/index.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!