An error is thrown if `renderToStaticMarkup` is used somewhere
See original GitHub issueTo 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:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
I still encounter it with
3.3.3
fixed in v3.2.3