react countup with visibility senor code example
Example: react countup with visibility senor
onVisibilityChange = (isVisible: boolean) => {
if (isVisible) {
this.setState({ didViewCountUp: true });
}
}
<VisibilitySensor
scrollCheck={true}
onChange={this.onVisibilityChange}
delayedCall >
<CountUp start={0} end={this.state.didViewCountUp ? 300000 : 0} duration={5} />
</VisibilitySensor>