Skip to content
Related Articles

Related Articles

How to show upload or download percentage in ReactJS ?

Improve Article
Save Article
Like Article
  • Last Updated : 12 Feb, 2021

We can show upload or download percentage in ReactJS using the CircularProgress Component with some core logic to show percentage. Material UI for React has this component available for us, and it is very easy to integrate. We can do it the ReactJS using the following approach.

Creating React Application And Installing Module:

Step 1: Create a React application using the following command.

npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command.

cd foldername

Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.

npm install @material-ui/core

App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.


import React from 'react';
import Box from '@material-ui/core/Box';
import CircularProgress from '@material-ui/core/CircularProgress';
export default function App() {
  const [uploadOrDownloadCount, 
         setUploadOrDownloadCount] = React.useState(10);
  React.useEffect(() => {
    const timer = setInterval(() => {
        (beforeValue) => (beforeValue >= 100 ? 0 
                          : beforeValue + 10));
    }, 800);
    return () => {
  }, []);
  return (
      <h4>How to show upload/download percentage in ReactJS?</h4>
      <Box position="relative" display="inline-flex">
        <CircularProgress variant="determinate" 
                          value={uploadOrDownloadCount} />

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!