-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ActionCableConsumer component unmounting/remounting on parent component rerender #26
base: master
Are you sure you want to change the base?
Conversation
I had the same problem. Was super annoying and was stuck debugging for 4 days with no working code. Switched back to the built in |
@csx773 - do you have an example? |
Would love to see this merged; seeing the exact same issue as described in our project. It's preventing messages from being transmitted because the component is re-rendering at the exact moment a message is sent, so it never transmits. |
I also would suggest this to be merged. It fixes the issue, and I'm currently using @ihollander branch in production |
I'm using the fork as well, with an extension of also adding in the ability for a component to re-render if the channel is changed. I didn't create a PR since I'm not sure if that's an isolated feature that our app needed, but if anyone would like to see it, it's here: |
I'm using @jordanhudgens' fork in my app currently! Thanks! |
When will this be closed and merged? |
(implement: PR26, see cpunion#26)
this is very useful, would love to see it merged :) |
+1 here |
this has been merged here JackHowa#6 -- also without react lifecycle warnings
thanks @marcelkooi for notifying me. Thanks @ihollander for the work. I added you as a collaborator to the project |
I am trying to use your forked repo in order to solve this same render problem but now I am facing a diferent one
Basically my setState hook function seems to not be called anymore, once participants inside |
huh @joaomosm, would be happy to take a look if I can with an example including the sockets call? feel free to post in the issues on my extension |
Would love to see this merged |
I've published this and people are using my fork @ryanflynndev |
This fixes the issue of the ActionCableConsumer component being unmounted and remounted every
time the parent component rerenders.
Since a new ActionCableConsumer class component was being created every time the forwardRef function runs, it was continually unmounting and mounting new versions of the component. This would also have the effect of unsubscribing and re-subscribing to the socket connection each time the parent rerenders, not just when the parent component unmounts.
I moved the createReactClass function outside of the forwardRef function and the component now behaves as expected.
Fixes #21