You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Intended outcome:
When changing JSX of func component that uses useSubscription, while webpack-dev-server --hot is running, underlying subscription should not be lost; i.e. source pushes should still result in useSubscription causing re-render.
Actual outcome:
After first change to func component, source changes pushed no longer cause useSubscription to cause re-render.
How to reproduce the issue:
Minimal setup of webpack, @pmmmwh/react-refresh-webpack-plugin, react-refresh
Simple breakpoint testing for a component fast-refreshed vs. one that has been unmounted appears to indicate adding && !this.isMounted solves the problem;i.e. this.isMounted === true when endSubscription called as part of fast-refresh processing, and this.isMounted === false when endSubsctiption called for a component no longer in (i.e. unmounting /ed or 'leaving') render tree.
On my apollo client 2.6 dev machine when I am doing development unrelated to apollo (css/jsx changes), I seem to occasionally get some errors about subscribeToMore being undefined. I haven't been able to figure out why or how to stop it. It feels related to this issue and it would certainly be nice for this to be fixed in 3.
Intended outcome:
When changing JSX of func component that uses
useSubscription
, while webpack-dev-server --hot is running, underlying subscription should not be lost; i.e. source pushes should still result inuseSubscription
causing re-render.Actual outcome:
After first change to func component, source changes pushed no longer cause
useSubscription
to cause re-render.How to reproduce the issue:
Minimal setup of webpack, @pmmmwh/react-refresh-webpack-plugin, react-refresh
Possible fix
I changed this:
apollo-client/src/react/data/SubscriptionData.ts
Line 145 in 0340c48
to this (quick hack in node_modules/@apollo... to see if would work)
Simple breakpoint testing for a component fast-refreshed vs. one that has been unmounted appears to indicate adding
&& !this.isMounted
solves the problem;i.e.this.isMounted === true
whenendSubscription
called as part of fast-refresh processing, andthis.isMounted === false
whenendSubsctiption
called for a component no longer in (i.e. unmounting /ed or 'leaving') render tree.Versions
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 14.2.0 - ~\AppData\Local\nvs\default\node.EXE
npm: 6.14.4 - ~\AppData\Local\nvs\default\npm.CMD
Browsers:
Edge: 44.18362.449.0
npmPackages:
@apollo/client: ^3.0.0-rc.2 => 3.0.0-rc.2
@apollo/link-ws: ^2.0.0-beta.3 => 2.0.0-beta.3
The text was updated successfully, but these errors were encountered: