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
I'm using re-frame 0.10.2. Following what was discussed in #218, I have form-1 components using subscriptions. In particular, they are subscriptions to a reg-sub-raw sub.
I'm also using hot-reload using figwheel, where my reload handler is:
When the page is loaded for the first time, everything's fine - render gets called once or twice, depending on what exactly the subscription does to the atom, but it stops after that and everything's ok.
However, when the hot-reload path gets triggered, it ends up in an infinite render loop; the render causes a new subscription to be created, the new subscription changes the value deref'd in the component, and that again causes a re-render with a new subscription being created.
If I comment out the clear-subscription-cache! call, things work as intended. That makes some sense based on the comment in #218 saying that it works because of the subscription cache (and sub dedup).
I'm not sure it matters ( I don't think it does) but in the reg-sub-raw-created subscription I'm creating a new reagent.core/atom instead of using the re-frame app-db. The subscription handler is a wrapper around the apollo graphql client, which implements its own cache, so using the app-db wouldn't really be productive here.
If I had to guess, what's happening is that the render method of the already-mounted component (as it's just reloading) gets called the second the subscription gets called, before it gets a chance to update the subscription cache. That render itself also causes a new subscription to be created, and, since the cache hasn't been updated yet, it just goes around in an infinite loop.
The text was updated successfully, but these errors were encountered:
bwalex
changed the title
form-1 components, reg-sub-raw subscriptions and clear-subscription-cache! render loop
form-1 components, reg-sub-raw subscriptions and clear-subscription-cache! infinite render loop
Jan 5, 2018
I'm using re-frame 0.10.2. Following what was discussed in #218, I have form-1 components using subscriptions. In particular, they are subscriptions to a reg-sub-raw sub.
I'm also using hot-reload using figwheel, where my reload handler is:
When the page is loaded for the first time, everything's fine - render gets called once or twice, depending on what exactly the subscription does to the atom, but it stops after that and everything's ok.
However, when the hot-reload path gets triggered, it ends up in an infinite render loop; the render causes a new subscription to be created, the new subscription changes the value deref'd in the component, and that again causes a re-render with a new subscription being created.
If I comment out the
clear-subscription-cache!
call, things work as intended. That makes some sense based on the comment in #218 saying that it works because of the subscription cache (and sub dedup).I'm not sure it matters ( I don't think it does) but in the
reg-sub-raw
-created subscription I'm creating a newreagent.core/atom
instead of using the re-frame app-db. The subscription handler is a wrapper around the apollo graphql client, which implements its own cache, so using the app-db wouldn't really be productive here.If I had to guess, what's happening is that the render method of the already-mounted component (as it's just reloading) gets called the second the subscription gets called, before it gets a chance to update the subscription cache. That render itself also causes a new subscription to be created, and, since the cache hasn't been updated yet, it just goes around in an infinite loop.
The text was updated successfully, but these errors were encountered: