noscript contents cause invariant violation
See original GitHub issueWhen using server rendering, putting an <img>
in a <noscript>
seems to invariably cause an invariant violation (it can’t find the image).
I believe this is because, to the JS enabled browser, the noscript content looks like CDATA.
This can be worked around by using dangerouslySetInnerHTML
to actually set the contents to an HTML string, however, you can’t nest components with this approach.
Issue Analytics
- State:
- Created 10 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Uncaught Error: Invariant Violation: findComponentRoot ...
$110): Unable to find element. This probably means the DOM was unexpectedly mutated.
Read more >The Noscript element - HTML: HyperText Markup Language
Permitted content, When scripting is disabled and when it is a descendant of the <head> element: in any order, zero or more <link>...
Read more >main.18b409e1.js.map - Google Git
n\n var error = new Error(message);\n error.name = 'Invariant Violation';\n error.framesToPop = 1; // we don't care about reactProdInvariant's own frame\n\n ...
Read more >React Error: Target Container is not a DOM Element-Reactjs
This error comes when the Javascript that tries to render the React component is included before the static parent dom element in the...
Read more >HTML Standard
Table of contents. 1 Introduction; 2 Common infrastructure; 3 Semantics, structure, and APIs of HTML documents; 4 The elements of HTML; 5 Microdata ......
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
I think this issue should be highlighted somewhere on the documentation.
The following seems to work well for me both on client and server (thanks to people above):
Noscript.js
Usage:
Now that we have
renderComponentToStaticMarkup
, maybe the best solution for this is just to do:where
c
is the component you want to render for people without JS.