-
Notifications
You must be signed in to change notification settings - Fork 787
ApolloProvider's shouldComponentUpdate causes silent issues when used with other providers, such as react router's #557
Comments
@ryancole out of curiosity, can you try and see what happens when you remove The PR that introduced it seems to have added it mostly out of caution. |
Hmm. I'm trying to run the tests but it says there are no matching tests ...
|
Implementing I currently can't upgrade to the latest react-apollo without refactoring a ton of code because of this issue. |
Just wanted to ping back in and mention that I did try running the tests, but I guess I don't know how to run them. As mentioned in my last post, jest says it finds no tests. |
@ryancole have tou tried simply running |
FWIW, I pulled latest from |
My use case has 4 react-routes, one of them uses Apollo to fetch graphql data, which takes about 5sec the first time. After that though every route change takes as long, even for routes that do not use Apollo data at all. My ApolloProvider wraps the router, because wrapping the route only breaks the app. What I mean is that this is a show stopper, and I'm sure it's a very common use case. |
It's been removed now! |
Does
ApolloProvider
need to implementshouldComponentUpdate
?I just updated my react-apollo version and suddenly my URL routing broke. Because I had only updated react-apollo, I started to track down what was now causing my application to no longer update when the URL changed (using react-router 4 for routing). After a bit of tinkering, I realized that if
ApolloProvider
was a parent component of react-router'sRouter
then the routing would work, but ifRouter
was the parent ofApolloProvider
things broke.So, I looked at git blame for
ApolloProvider
'sshouldComponentUpdate
and see that it was added in a version more recent than the one I had been using. WhenApolloProvider
is a child ofRouter
the entire routing breaks becauseApolloProvider
will silently refuse to update itself.In a typical web application, it's almost guaranteed that there will be several "provider" components and none really specify how they need to be used in conjunction with other providers. I think most providers appear to skip implementing
shouldComponentUpdate
though because it can cause the whole application to never update.Does
ApolloProvider
really need to implement this? If so, I think it should be noted in the docs, if it's not. Ideally somehow there could even be a runtime warning if it detects that you've got aRouter
child or something, but that's definitely too specific of a warning for this tool.The text was updated successfully, but these errors were encountered: