After server-side renderToString() component claims it isMounted()
See original GitHub issueIf you keep a _this
reference at the componentWillMount()
lifecycle method of a component that is then rendered with renderToString()
, then _this.isMounted() === true
later on. The documentation however claims that server-side components aren’t really mounted; since componentDidMount()
is never called.
I think this behavior changed in React 0.14 but that might be wrong.
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
A beginner's guide to React Server-Side Rendering (SSR)
The renderToString() method does not execute any lifecycle methods including componentDidMount() . The only methods of a React component ...
Read more >useLayoutEffect in ssr · Issue #14927 · facebook/react - GitHub
renderToString() is being used on the client. ... conditionally render the component after initial render and render a fallback first since ...
Read more >Tag: Server-side Rendering - somewhat abstract
Using a hook or stateful component to delay client-specific code until after the initial render is a versatile solution to many hydration issues....
Read more >ReactDOMServer – React
The following methods can be used in the environments that don't support streams: renderToString(); renderToStaticMarkup(). Reference. renderToPipeableStream().
Read more >React Server Side rendering: how can I know my component ...
My mistake. As from this answer componentDidMount isn't called on the server-side. So I can go: var Component = React.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
(Unrelated, but
invokeComponentDidMountWithTimer
is not a good place to do anything—it is only called in DEV. It specifically exists so we don’t pay for unnecessary indirection and/or code size.)isMounted can have many meanings and there’s no clear correct one so I’m inclined to leave the current behavior even though it’s a little bit confusing. Non-createClass classes do not support isMounted anyway.