I'm using React hooks and i want my component to actually do the entire loading before displaying it.
My current solution is currently this:
import React, {useState, useEffect} from 'react'
import Main from './Main'
export default function Container() {
const [isLoading, setisLoading] = useState(false);
useEffect(() => {
setTimeout(() => setisLoading(true), 1000)
})
return (
<div>
{(isLoading) ? <Main/> : <h1>I'm currently loading</h1>}
</div>
);
}
The issue here is that it load's for 1 second and then displays my Main.js component which takes ~2 seconds to load. I want the actually loading to be done before it displays the component.