Component not re-render in apollo-link-state after upgrading apollo-cache-inmemory to 1.3.*
See original GitHub issueIntended outcome:
I use apollo link state to save an array of objects to the local client. In apollo-cache-inmemory 1.2.10, the component is able to re-render on pushing new items to the array or deleting one item from the array. After upgrading to 1.3.5, I expected everything would stay the same.
Actual outcome:
However the component fails to re-render at all with 1.3.*.
How to reproduce the issue:
apollo-cache-inmemory 1.2.10:
https://codesandbox.io/s/l99l9r1ml9 (There’s an issue with codesandbox. I have to double click the buttons to trigger the re-render, but on my local, there’s no such issue.)
apollo-cache-inmemory 1.3.5
https://codesandbox.io/s/8xqn9mz0l (It doesn’t work at all, even if I double click either buttons)
Versions
"dependencies": {
"graphql": "0.13.2",
"react": "16.5.0",
"apollo-cache-inmemory": "1.3.5",
"apollo-link-state": "^0.4.2",
"apollo-link-http": "1.5.5",
"react-apollo": "2.2.4",
"react-dom": "16.2.0",
"apollo-client": "^2.4.2",
"graphql-tag": "^2.10.0"
},
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:33 (15 by maintainers)
Top Results From Across the Web
React not re-rendering child component after updating state ...
The Grid component's resetPaint state var is changed from false to true; This causes a re-render of Grid with resetPaint set to true;...
Read more >@apollo/client | Yarn - Package Manager
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components...
Read more >apollo-cache-inmemory - npm
Core abstract of Caching layer for Apollo Client. Latest version: 1.6.6, last published: 3 years ago. Start using apollo-cache-inmemory in ...
Read more >Migrating to Apollo Client 3.0 - Apollo GraphQL Docs
Updating imports. The @apollo/client library includes functionality that previously required installing additional packages. As part of migrating to Apollo ...
Read more >5 Ways to Avoid React Component Re-Renderings
So, it will not re-render the component if the user clicks the same item again and ... React Query library has more than...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Similar issue here going from 1.2.10 to 1.3.5, though I’m using
readQuery
/writeQuery
in theupdate
callback of a mutation. I was using.push
to add something to a nested array and writing the data back, but nothing re-rendered. I now have to provide a new top level object to get it to re-render (which I can do with an immutability library, but will require updating hundreds of callbacks in our app).I also did this based on the documentation examples mutating the cache results:
Fix incoming with https://github.com/apollographql/apollo-client/pull/4032.