#Dynamic Server Usage
1 messages · Page 1 of 1 (latest)
[Rendering Suspense fallback...: DYNAMIC_SERVER_USAGE] { digest: 'DYNAMIC_SERVER_USAGE' } error - [Rendering Suspense fallback...: DYNAMIC_SERVER_USAGE] { digest: 'DYNAMIC_SERVER_USAGE', page: '/' } error - [Rendering Suspense fallback...: DYNAMIC_SERVER_USAGE] { digest: 'DYNAMIC_SERVER_USAGE', page: '/' }
How do I even troubleshoot what is going wrong?
I had a component tree of:
Layout > Suspense > UserInfo
Both UserInfo and Layout were trying to utilize the useCurrentUser Hook. Is it possible that attempting to use this hook both inside suspense and outside suspense was causing the grief? It seems to work fine if the useCurrentUser hook is used in the top component and fed as props to both Layout and UserInfo
^^ the above seems unrelated
I think it may have been a bad import?
Im not really sure tbh
Solved! The issue here is attempting to use a hook in a component that is not protected by a suspense boundary.
This means that if you intend to use a hook in your Layout component, youll want to go into your _app.tsx and add your <Suspense> component just inside your error component around your call to getLayout as in the following example:
function MyApp({ Component, pageProps }: AppProps) { const getLayout = Component.getLayout || ((page) => page) return ( <ErrorBoundary FallbackComponent={RootErrorFallback}> <Suspense fallback={<div>Loading...</div>}> {getLayout(<Component {...pageProps} />)} </Suspense> </ErrorBoundary> ) }
Can you please try to explain me why this error happens I keep getting it even if I've wrapped the getlayout function with Suspense
Im getting it rn on a brand new blitz project
fresh off the press and it errors out
in your hook file, you can encapsulate the useQuery or the useMutation with a try catch and it wont cause an unhandled error to be thrown. I know it doesnt stop the error from happening completely, but for me at least, it isn't actually breaking functionality so I just honestly want to silence it.
hope this helps