React introduced shallow rendering in 0.13. This is an excellent feature that I wish was included earlier in React. It aims to solve the problem of unit testing components without going through a real, or jsdom mocked, DOM. I couldn't find any info online about what lifecycle events it actually fires. So I did some testing of my own. To reproduce, put component.js
and test.js
into a folder and run node test.js
.
TLDR; shallow rendering only invokes the following lifecycle hooks (in order):
getDefaultProps
getInitialState
componentWillMount
stops here until re-rendercomponentWillReceiveProps
shouldComponentUpdate
componentWillUpdate