-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iframe contents cause invariant violation #1253
Comments
@matthewwithanm I'm guessing the IE8 problems you saw in #1327 won't be a problem here -- want to try the same renderToStaticMarkup approach? |
I'm not sure if that really fits here… With |
Correct me if I'm wrong, but the contents will be used only if the browser doesn't support iframes, which basically all browsers that support JS should? |
I'm not sure how iframe support correlates with JS support (or whether you can disable them). Does it not matter that the browser changes the content? I would've thought that would trigger an error, even if the elements didn't have React IDs. |
React shouldn't look inside the iframe unless you change the contents later. |
Hi all, I also came up with a case of invariant violation of an Here is how I solved it though: import { renderToStaticMarkup } from 'react-dom/server';
export const serverGtmNoScript = `<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe>`;
export const clientGtmNoScript = renderToStaticMarkup(serverGtmNoScript); and in our Layout render function: <noscript
dangerouslySetInnerHTML={{
__html: process.browser ? clientGtmNoScript : serverGtmNoScript,
}}
/> Error message for Google Search:
p.s. I am now seeing other invariant warnings with the move to React 16... |
@damusnet The best way to report problems with React 16 is to file new issues. It is likely your problems are entirely unrelated to the issue being discussed here, and because the discussion is buried in a three year old thread, we won’t know about those problems. |
@Gaeron alright, thanks! I wasn't sure this deserved a new issue but I'll open one now. |
When using server rendering, putting an
<img>
in an<iframe>
seems to invariably cause an invariant violation (it can't find the image).This is related to #1252, but not identical. In both cases, the browser isn't aware of the inner elements however, in this case, it's because browsers that support iframes are actually mutating the DOM (by replacing the contents with the document specified in the
src
attribute).The text was updated successfully, but these errors were encountered: