thunderstore-io / thunderstore-ui

Thunderstore React UI
11 stars 5 forks source link

Fix issues with rehydration of components that use Dapper #1002

Closed anttimaki closed 9 months ago

anttimaki commented 9 months ago

I'm not 100% certain I understand everything that's going on here, but it seemed components that call useDapper and don't have "use client" defined work nicely when building the project or when accessed in the browser with a direct url (server-side rendered?). But then they break when accessed by navigation from another page (client-side rendered?).

Error messages shown on server's logs show that when rehydrating(?) the page neither ServerDapper nor ClientDapper context provided the Dapper for these pages. Also it seemed that the errors were logged before the actual navigation event, but this might be due NextJs prefetching the content. The error didn't affect components that fetched content with Dapper without navigation (e.g. changelog tab on package listing page).

Or I might be completely misunderstanding this.

Anyway, adding "use client" seemed to fix the issue, so this commit adds it to all components that call useDapper, just to be safe.

Refs TS-1896