balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

ProgressBar.js (438B)


      1 const {useState, useEffect, memo} = wp.element;
      2 import CONFIG from '../config';
      3 export default memo(function ProgressBar({currentStep}){
      4     const [width, setWidth] = useState(0);
      5     useEffect(() => {
      6         setWidth( currentStep <= 0 ? 0 : (currentStep / CONFIG.totalStep * 100) );
      7     }, [currentStep])
      8     return (
      9         <div className='challenge-bar'>
     10             <div style={{width: width + '%'}}></div>
     11         </div>
     12     );
     13 });