Loading state
Unanswered
Hairy Woodpecker posted this in #help-forum
Hairy WoodpeckerOP
My layout.js file needs to know the loading state of the page.
Right now my loading.js file works great while my page is loading. But I need to display a loading bar in my layout.js file while the loading page is displaying. I’ve tried setting up a global context but I cannot set the global state from within the loading.js file. Is there any way for my layout.js file to know if the loading.js file is displaying? Thanks
Right now my loading.js file works great while my page is loading. But I need to display a loading bar in my layout.js file while the loading page is displaying. I’ve tried setting up a global context but I cannot set the global state from within the loading.js file. Is there any way for my layout.js file to know if the loading.js file is displaying? Thanks
8 Replies
Golden paper wasp
If you're using app dir then you can use loading.js to show loading state
Hairy WoodpeckerOP
Okay but what about needing to show a loading bar inside of layout.js
Golden paper wasp
Do you mean loading indicator on top for route change like youtube??
Hairy WoodpeckerOP
I just need a way for the layout.js to know that the page is loading
Cape lion
what parts of the page are loading?
Hairy WoodpeckerOP
The page is loading and the layout needs to have a loading bar inside while the page loads
Cape lion
again, which parts of the page? are you loading async data? or is the page pre-rendered with SSG or SRR? or
sorry i think you need to be more spcific with the question