Advanced-React icon indicating copy to clipboard operation
Advanced-React copied to clipboard

Update Search.js to include ssr: false field in useLazyQuery

Open TimmDay opened this issue 3 years ago • 1 comments

I was getting infinite browser hang (chrome) due to an ssr issue with Next and Apollo useLazyQuery. This fixes it

Hi! Thanks for the course :). I'm not sure why this didn't show up during the course (Possibly because I'm using newer versions of next and apollo-client).

Anyway I think that the issue was that useLazyQuery was being server side rendered but can't be executed on the server since it is triggered after ssr is finished? The page would successfully build, but the browser would never display the app. Something or other wasn't resolving properly. I added the ssr: false flag to the useLazyQuery options and that fixes it.

I'd love to hear your thoughts and hope that this is helpful.

Have a good one from Australia. Tim

TimmDay avatar Dec 23 '21 03:12 TimmDay

Hey @TimmDay

The issue was fixed in this PR - you need to use @apollo/client version 3.4.0 🙂

https://github.com/wesbos/Advanced-React/pull/283

Asjas avatar Dec 23 '21 13:12 Asjas