Description
As discussed on IRC, the lifecycle functions are misleading when using renderComponentToString
. Namely, because componentWillMount
is called, but componentDidMount
is not.
At the least, this should be documented on the lifecycle docs page. There was also discussion about changing the method names. (Note: there's clearly a need for both hooks; the only issue is that name of the former conveys that the component will mount when, in fact, it won't.)
One possibility is to add another always-run phase before the mounting phase which is run when rendered to string or DOM (e.g. "prepare" or "initialize"). The lifecycle would then be easily explained as follows:
- Prepare the compoent
- Mount the component (if rendering to DOM)
- Render the component for the first time.
I'd be happy to contribute a PR for either docs, method names, or both once a decision is reached.