Closed tordans closed 7 months ago
I also faced this issue while doing server-side rendering, I noticed that when I'm able to access my page by going from "/" to "/dashboard" BUT can not access "/dashboard" directly. In my component, I want to use useQuery
to render my component. (dateString
props is passed by dynamic page rendering)
// Dashboard.jsx
const Calendar = ({ dateString }: { dateString?: string | undefined }) => {
let currentDate: Date = new Date();
if (dateString) {
currentDate = convertDateStringToDate(dateString);
}
const [scheduledClasses] = useQuery(getClasses, {
dateString,
});
// ...other code
return ( // .... )
}
The error won't appear if I removed useQuery
but it is not what I want. I temporarily fixed this by forcing the code to use client-side rendering with this trick:
// DashboardLayout.jsx
const [render, setRender] = useState(false);
useEffect(() => {
setRender(true);
}, []);
// ...
<AppShell.Main>{render && children}</AppShell.Main>
by forcing the code to use client-side rendering
I have 'use client'
in every file in the app directory + blitz-client. This seems to be needed, since BlitzProvider
is a client component (I just opened https://github.com/blitz-js/blitzjs.com/pull/847 to clarify this in the docs).
My understanding is, that the use client
directive makes it a client component.
I temporarily fixed this by forcing the code to use client-side rendering with this trick…
I tried your setRender
workaround in https://github.com/FixMyBerlin/blitz-test/commit/e31eeedc41f45fe3a6b0e2e5cbb747c522891028 but that has no effect on the error:
And adding it to the layout as well causes new hydration errors.
It looks like this error came from a library that we used 'osm-auth'. Once I remove it, the error is gone. I will close this here and referenced it at https://github.com/osmlab/osm-auth/issues/124.
@siddhsuresh FYI I reopened this ticket. We managed to somehow get rid of the error in our main flow which is why I thought it was related to the library I mentioned but that was wrong and I could have know because the demo app that this bug report is based on (https://github.com/FixMyBerlin/blitz-test) shows the error without without any special dependencies.
Thanks for the update @tordans I will take a look in some time.
Ran into this issue while migrating a Blitz app from pages router to app router. Managed to isolate the issue to useQuery
.
@NoahJinnn's fix of forcing the page to render client side with the useEffect()
hook worked for me.
What is the problem?
I created a fresh blitz app, added a
project
model with some user relation and migrated it to the app directory.The app now shows the error message
Ping https://github.com/blitz-js/blitz/issues/4112 and https://github.com/blitz-js/blitz/issues/4149 but this is based on the newest blitz and next js versions.
Paste all your error logs here:
Demo app is here https://github.com/FixMyBerlin/blitz-test
Paste all relevant code snippets here:
-
What are detailed steps to reproduce this?
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response