Apollo-client: local cache updates but React does not re-render (sandbox link supplied)

Created on 14 Mar 2019  路  4Comments  路  Source: apollographql/apollo-client

I have two local states stored in the cache, and there is one component using them via compose. In the example, I am using a Dialog state and Drawer state.

Intended outcome:
Use the following clicking sequence to test the example below.

Open Dialog -> Close Dialog (working as expected)
Open Drawer -> Close Drawer (working as expected)
Open Dialog -> Close Dialog (now stopped working)
Open Drawer -> Open Dialog -> Close Dialog (not working, the dialog should be closed)

Actual outcome:

Use the following clicking sequence to test the example below. The bug happens when you open Dialog, close Dialog, then open drawer and close drawer.

Open Drawer -> Close Drawer (working as expected)
Open Dialog -> Close Dialog (working as expected)
Open Drawer -> Open Dialog -> Close Dialog (not working, the dialog should be closed, but it hangs. Cache is updated, but the component does not re-render)

How to reproduce the issue:
https://codesandbox.io/s/z32vxpm2kx

Versions
latest

Most helpful comment

@leogoesger @OurMajesty I have a fix ready for this, and will get it into a PR shortly (I'm just finalizing tests).

All 4 comments

@hwillson do you know if this is something I am doing wrong, or there is indeed a bug somewhere in Apollo?

@leogoesger I think you did everything right. At least I am having similar issue which is caused by react-apollo. If you try [email protected] instead (which I did try in your reproduction), then you'll see it works.

@hwillson Should I try to create example too? Or you are having all information you need?

@leogoesger @OurMajesty I have a fix ready for this, and will get it into a PR shortly (I'm just finalizing tests).

JFYI, this error is fixed in [email protected]

Was this page helpful?
0 / 5 - 0 ratings