Hello,
This is more a fix suggestion than a question.
I wanted to use a very simple loading screen like this:
copy return ( <> <LayoutSplashScreen visible={showSplashScreen} /> {children} </> )
The issue was that it not worked as expected.
First of all, the app is not wrapped in MetronicSplashScreenContext.
Secondly, I found that in LayoutProvider there is a line that hides the splash screen on Layout render, no matter what:
copy useEffect(() => { disableSplashScreen() }, [])
To solve this, as a quick workaround, I passed the visible variable from the context:
copy <MetronicSplashScreenContext.Provider value={{setCount, visible}}> {children} </MetronicSplashScreenContext.Provider>
and imported in LayoutProvider to not override this like below:
copy const [splashScreenShown, setSplashScreenShown] = useState(false) const {visible} = useContext(MetronicSplashScreenContext) useEffect(() => { if (visible && !splashScreenShown) { setSplashScreenShown(true) } else if (!visible && splashScreenShown) { disableSplashScreen() } }, [visible, splashScreenShown, disableSplashScreen])
This works and LayoutSplashScreen can be now rendered from anywhere within the context.
It would be great if a fix similar to this would be implemented so that the SplashScreen component can be easily used and properly update like so:
copy <LayoutSplashScreen visible={showSplashScreen} />
I use the latest version of react demo2 by the way. Let me know if I missed something.
Thanks!
Tamas