Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How to show loading screen with process status with in react.js ? [closed]

By M.K. Verma · 2 May 2022

How to show loading screen with process status with in react.js ? [closed]

Try This 

import React, { useState, useEffect } from 'react';
import Spinner from './your-custom-component';

export default MyComponent = () => {
  const [isLoading, setIsLoading] = useState(true); // When the page loads it must be true;
  
  useEffect(() => {
    setIsLoading(false);
  }, []); // Initial render

  const handleUpdate = async () => {
    setIsLoading(true);
    await performAsyncOpHere();
    setIsLoading(false);
  }

  return isLoading? <Spinner /> : <fancy-html />
}