question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After server-side renderToString() component claims it isMounted()

See original GitHub issue

If 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:closed
  • Created 8 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jun 27, 2016

it’d be better attach a flag in invokeComponentDidMountWithTimer indicating it mounted?

(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.)

0reactions
sophiebitscommented, Aug 18, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found