import React from "react"; import "./index.scss"; export default class ProgressBar extends React.Component { state = { percent: 0, }; componentDidMount() { this.percentInterval = setInterval(() => { this.setPercent(); }, this.props.interval); } componentWillUnmount() { clearInterval(this.percentInterval); } setPercent = () => { this.setState({ percent: this.state.percent + this.props.offset }); }; render() { return ( <> {window.innerWidth > 1000 ? (
{this.state.percent ? ( {this.state.percent}% ) : null}
) : null} {window.innerWidth < 1000 ? (
{this.state.percent ? ( {this.state.percent}% ) : null}
) : null} ); } }