-
Notifications
You must be signed in to change notification settings - Fork 10
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
Tear Down client when Split Factory Component Unmounts #2
Tear Down client when Split Factory Component Unmounts #2
Conversation
This is even more than a fix, is a good practice destroy your listeners on destroy the component. |
Hey @drewmendenhall ! Thank you very much for submitting the PR! our apologies for dropping the ball on replying to you. I went ahead and scheduled this to be picked up next week from our end, we'll let you know here how it goes. @nathanredblur For the time being, maybe you can get around it by getting the client through the Best, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @drewmendenhall , We will merge your PR into |
@EmilianoSanchez would it help if I rebased to squash the fixup commit? or did you already plan on that? edit after reviewing that commit: looks like it might be better to un-pick it and write a better test 😄 |
No. It is okey.
Yes. Actually, we are updating some tests and polishing the code. So, probably your test will be modified a little bit. I will handle that :) |
React SDK
What did you accomplish?
If / when the component unmounts, the client (event emitter) is leaked. This change cleans up the client on unmount.
How do we test the changes introduced in this PR?
Would a spy on
client.destroy()
suffice? I have made an attempt, please see the split-out fixup commit. I will give it another shot soon, but you might be able to help quicker.Extra Notes
The larger issue is that there are cases where the
id
prop changes. Example scenario: a user begins unauthenticated, and is given a temporary split id. The use logs in and now their split id can be set to an id the application can identify the user with.For a SPA, the
SplitFactory
element remains mounted, but a new id is passed. If I understand correctly, this component does not react to any prop changes once mounted. So a stop-gap solution is to set the element'skey
to the same asid
to tell (or trick) React to un-mount the existingSplitFactory
instance and mount a new one with the new id. This change is a good idea regardless.componentDidUpdate
(or a hooks migration) can be implemented at a later time.