import React from "react"
import { CountUp } from 'countup.js';
class Counter extends React.Component {
constructor(props) {
super(props);
this.counterRef = React.createRef();
}
componentDidMount() {
this.initCounter();
}
initCounter = () => {
if (this.counterRef.current) {
console.log(this.counterRef);
const countUp = new CountUp(this.counterRef.curent, 5234);
if (!countUp.error) {
countUp.start();
} else {
console.error(countUp.error);
}
}
}
render() {
return (
<div ref={this.counterRef}/>
);
}
}
export default Counter;