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.

An error is thrown if `renderToStaticMarkup` is used somewhere

See original GitHub issue

To reproduce, add anywhere on top-level of your app:

class MyComponent extends React.Component {
  render() {
    return null
  }
}
const string = React.renderToStaticMarkup(<MyComponent/>);

Error in console:

Uncaught TypeError: Cannot read property 'mode' of undefined
    at whyDidYouRender.min.js:8
    at f.value (whyDidYouRender.min.js:8)
    at processChild (react-dom-server.browser.development.js:2958)
    at resolve (react-dom-server.browser.development.js:2811)
    at ReactDOMServerRenderer.render (react-dom-server.browser.development.js:3201)
    at ReactDOMServerRenderer.read (react-dom-server.browser.development.js:3160)
    at renderToStaticMarkup (react-dom-server.browser.development.js:3660)

Looks like renderToStaticMarkup doesn’t set _reactInternalFiber property on component instances

Here’s my usecase for renderToStaticMarkup: in my app, there are only some parts rendered by React, while other are rendered by server templates. To use third-party (BitBucket) svg icon in non-React parts of the app, I convert a React component from Atlaskit library to static svg string with renderToStaticMarkup, and then inject it in a CSS rule.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Hypnosphicommented, Sep 9, 2019

I still encounter it with 3.3.3

1reaction
vzaidmancommented, Jul 23, 2019

fixed in v3.2.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactDOMServer.renderToStaticMarkup gets stuck while ...
So is the expected behavior that we throw an error when trying to render a Portal using ReactDOMServer ?
Read more >
Is it ok to use ReactDOMServer.renderToString in the browser ...
When I try to use renderToStaticMarkup in the browser it gives me an unresolved package error after transpiling, saying it's looking for "stream ......
Read more >
ReactDOMServer – React
The following methods can be used in the environments that don't support streams: renderToString(); renderToStaticMarkup(). Reference. renderToPipeableStream().
Read more >
How to Read React Errors (fix 'Cannot read property of ...
First order of business is to figure out where the error is. If you're using Create React App, it probably threw up a...
Read more >
React Error Handling And Reporting With Error Boundary And ...
When an error is thrown inside a component, the error boundary is the first line of defense. In our last illustration, if an...
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