Baterka
Baterka

Reputation: 722

React - componentWillMount memory leak

I watched this video about componentWillMount can cause memory leak: https://www.youtube.com/watch?v=Fgd2ivSnXXo

I tested it myself with checking for listeners by console.log(TodoStore.listenerCount("change")); but it seems there is no multiple listeners anymore.

Is this problem fixed by React or I am still supposted to use componentWillUnmount() to destroy listener?

Upvotes: 1

Views: 329

Answers (1)

Baterka
Baterka

Reputation: 722

componentWillMount not causing memory leak anymore and it is reccomended to use componentDidMount as drop-in replacement, because componentWillMount is deprecated.

Upvotes: 1

Related Questions