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]](/_next/image?url=https%3A%2F%2Fserveapi.trimwebsolutions.com%2Fuploads%2Flegacy%2Fblog%2F16515006831651500683.jpg&w=3840&q=65)
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 />
}