Odometer in ReactJS

1.3k views Asked by At

I'm trying to run the Odometer, but it is not running in my JSX file. Am I following something wrong ? I can only see static numbers.

Landing.jsx:

import Odometer from 'react-odometerjs';
.
.
.
<div className="counter">
<div className="number odometer" id="datasources">
<Odometer value={11} format="(,ddd)"/></div>
<div className="label">underlying datasets</div>
</div>

3

There are 3 answers

2
Muhammad Zeeshan On

Try the format as:

<Odometer value={1234} format="(.ddd),dd" />
0
Josh Wulf On

You need to create a timer that changes the value of the innerHTML of the odometer element. The odometer class uses a MutationObserver to detect the change and update itself.

0
Josue Romero On
  • You need to put the type of animation. for example
<Odometer value={11} format="(,ddd)" animation="count"/>
  • Don't forget to import the css file in your app .
https://raw.githubusercontent.com/HubSpot/odometer/master/themes/odometer-theme-default.css