Closed
Description
Repeated calls to renderComponentToString with evented components (i.e. onClick={this.handleClick}) will effectively leak memory.
Call unmountComponent on rendered components lest event listening closures remain non-garbage collected.
Only long lived processes with repeated render calls will notice.
Adding component.unmountComponent() at ReactServerRendering.js:54 would fix this, but would break tests which render react root document nodes with an Invariant Violation.
var Link = React.createClass({
leak: function(event) {
},
render: function() {
return <a onClick={this.leak} >Test</a>;
}
})
function log(str) {
console.log(str);
}
var root = <html><body><Link /></body></html>
React.renderComponentToString(root, log);
root.unmountComponent();
renderComponentToString is API bound to be async so this sample is not future proof.
Metadata
Metadata
Assignees
Labels
No labels