adamsoffer / next-apollo

React higher-order component for integrating Apollo Client with Next.js
MIT License
482 stars 64 forks source link

Why does it have to be a HOC? #80

Open botoxparty opened 3 years ago

botoxparty commented 3 years ago

Hey,

So i've been working on a project that uses Next.js and Apollo client. We had some issues with page re-renders because the Apollo client was being re-instantiated on route changes.

Wrapping the App in a HOC definitely fixes the problem and I see this pattern being used for this problem everywhere online. I'm trying to understand why this works and maybe what are the other potential solutions to a problem like this?

Thanks for your work on this package btw.

Cheers Adam