Skip to content

Conversation

@glenn-murray-bse
Copy link

Fixes #954, changes React.renderComponentToString to no longer register events

New exposed methods

EventPluginHub.setRegistrationEnabled(boolean)
EventPluginHub.isRegistrationEnabled() // returns boolean

Glenn Murray added 5 commits January 24, 2014 11:22
renderComponentToString registers events. If the calling code
does not unmount the component or unregister the listeners
this will leak memory. Passing this test should fix this.
Flag on EventPluginHub to disable event registration.
For the purposes of server side rendering not registering events.
Could be cleaner if used a transaction with an optional step.
Alternatively could be an ExecutionEnvironment variable.
Could also be flag passed to mount component, however non DOM
components have no comprehension of events.
EventPluginHub.setRegistrationEnabled(boolean) will toggle
whether putListener will register event listeners.
@petehunt
Copy link
Contributor

Hey @glenn-murray-bse --

Super sorry about not making this clear but I actually just landed a fix for this internally which will be synced soon. I ended up doing the diff a little differently -- I added a new type of queue to ReactReconcileTransaction that would call putListener() after the DOM flush so we wouldn't need to pass around a flag like this.

I want to highlight that this was a great PR -- it's awesome to see you jump headfirst into the event system and write tests. Though we don't need this particular PR, we'd certainly love more contributions from you in the future :)

Thanks again, and my apologies,

Pete

@petehunt petehunt closed this Jan 24, 2014
@plievone
Copy link
Contributor

@petehunt I wonder why putListener() is called even if container is not found? https://github.com/facebook/react/blob/0af9c3e/src/core/ReactDOMComponent.js#L76

@glenn-murray-bse
Copy link
Author

No worries, adding an optional step to TRANSACTION_WRAPPERS was an initial idea I had, I agree that transactions are a better way of dealing with this than flags.

I'll better get my head around the transaction implementation next time I dive in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

renderComponentToString with events leaks unless component unmounted

3 participants