I have been trying to implement react counterup along with react-visibility sensor. I wish to show the couterup only after that section is visible in the viewport. So, Using the visibility sensor to load it. But, it's not working and below is the error
"Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object."
Sample code is below
import React from 'react';
import CountUp, { startAnimation } from 'react-countup';
const CounterSection= (props) => {
const VisibilitySensor = require('react-visibility-sensor');
function onChange(isVisible) {
console.log('Element is now %s', isVisible ? 'visible' : 'hidden');
}
return (
<div>
<VisibilitySensor onChange={onChange}>
<div>...content goes here...</div>
<CountUp start={0} end={9350} duration={5} />+
</VisibilitySensor>
</div>
);
};
Assistance on this much appreciated. Thanks