The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

LayoutSplashScreen doesn't work, metronic 7 react

i need proper example of splash screen logic

<pre> export default function App({ store, persistor, basename }) { return ( /* Provide Redux store */ <Provider store={store}> {/* Asynchronously persist redux stores and show `SplashScreen` while it's loading. */} <PersistGate persistor={persistor} loading={<LayoutSplashScreen />}> {/* Add high level `Suspense` in case if was not handled inside the React tree. */} <React.Suspense fallback={<LayoutSplashScreen />}> {/* Override `basename` (e.g: `homepage` in `package.json`) */} <BrowserRouter basename={basename}> {/*This library only returns the location that has been active before the recent location change in the current window lifetime.*/} <MaterialThemeProvider> {/* Provide `react-intl` context synchronized with Redux state. */} <I18nProvider> {/* Render routes with provided `Layout`. */} <Routes /> </I18nProvider> </MaterialThemeProvider> </BrowserRouter> </React.Suspense> </PersistGate> </Provider> ); } </pre> <pre> import React, {createContext, useContext, useState, useEffect} from "react"; const MetronicSplashScreenContext = createContext(); export function MetronicSplashScreenProvider({ children }) { const [count, setCount] = useState(0); let visible = count > 0; useEffect(() => { const splashScreen = document.getElementById("splash-screen"); // Show SplashScreen if (splashScreen && visible) { splashScreen.classList.remove("hidden"); return () => { splashScreen.classList.add("hidden"); }; } // Hide SplashScreen let timeout; if (splashScreen && !visible) { timeout = setTimeout(() => { splashScreen.classList.add("hidden"); }, 3000); } return () => { clearTimeout(timeout); }; }, [visible]); return ( <MetronicSplashScreenContext.Provider value={setCount}> {children} </MetronicSplashScreenContext.Provider> ); } export function LayoutSplashScreen({ visible = true }) { // Everything are ready - remove splashscreen const setCount = useContext(MetronicSplashScreenContext); useEffect(() => { if (!visible) { return; } setCount(prev => { return prev + 1; }); return () => { setCount(prev => { return prev - 1; }); }; }, [setCount, visible]); return null; } </pre>
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


I've just checked the code, and it works, as expected. In case we comment on it, I see a splash screen from 'public/index.html' file. But we are using it only for the first application load. If you need something for your Suspent fallback= you have to implement your own SplashScreen component.

Regards,
Keenthemes support



Hi Alexander,

I will check your case tonight and will come back with a response then (cause it's Metronic 7, the current version is 8.0.36 and it takes some time to run+test the case).

Regards,
Keenthemes support


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.