Skip to content

Commit

Permalink
remove mem leak warning from debug
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 19, 2022
1 parent 55f0a84 commit 64d0f82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-cars-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact': minor
---

Remove memory leak warning from debug
7 changes: 0 additions & 7 deletions debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,6 @@ Component.prototype.setState = function(update, callback) {
)}`
);
}
} else if (this._internal.flags & MODE_UNMOUNTING) {
console.warn(
`Can't call "this.setState" on an unmounted component. This is a no-op, ` +
`but it indicates a memory leak in your application. To fix, cancel all ` +
`subscriptions and asynchronous tasks in the componentWillUnmount method.` +
`\n\n${getOwnerStack(this._internal)}`
);
}

return setState.call(this, update, callback);
Expand Down
23 changes: 0 additions & 23 deletions debug/test/browser/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,29 +204,6 @@ describe('debug', () => {
expect(console.warn).to.not.be.called;
});

it('should warn when calling setState on an unmounted Component', () => {
let setState;

class Foo extends Component {
constructor(props) {
super(props);
setState = () => this.setState({ foo: true });
}
render() {
return <div>foo</div>;
}
}

render(<Foo />, scratch);
expect(console.warn).to.not.be.called;

render(null, scratch);

setState();
expect(console.warn).to.be.calledOnce;
expect(console.warn.args[0]).to.match(/no-op/);
});

it('should warn when calling forceUpdate inside the constructor', () => {
class Foo extends Component {
constructor(props) {
Expand Down

0 comments on commit 64d0f82

Please sign in to comment.