How to mock componentDidMount or overwrite it in React?

Posted by Andre Scott | Updated on

Want to mock componentDidMount or overwrite it in React? I prefer the following approach, but requires using ES6 classes.

The point is to create an on demand ChildClass inheriting the OriginalClass, do whatever overrides and then TestUtils.renderIntoDocument().


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers