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.

Chrome extension breaks styled in SSR

See original GitHub issue

Current behavior:

Styled is broken by some browser extensions. For example: Urban VPN Proxy

To reproduce: A minimal reproduction demo is created here with detailed description.

Expected behavior:

Extension should not affect styled if not intensional.

Environment information:

  • react version: ^18.2.0
  • @emotion/react version: ^11.10.5

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lucascurticommented, Nov 24, 2022

Thanks @Andarist for looking into it and @flappyBug for the workaround. Another thing that gets rid of the issue is taking the Chakra UI approach to set up emotion: https://chakra-ui.com/getting-started/remix-guide

1reaction
flappyBugcommented, Nov 24, 2022

@lucascurti Currently we have a workaround to remove all the elements we don’t recognize before hydration. e.g. in your entry.client.tsx, before hydration:

document
  .querySelectorAll('html>:not(head,body)')
  .forEach((e) => document.documentElement.removeChild(e));
hydrate(<RemixBrowser />, document);

One drawback of this approach is that it may partially break some extensions’ functionality. I didn’t test it though, one may restore it after hydration:

const tamperedNodes = document
  .querySelectorAll('html>:not(head,body)');
tamperedNodes.forEach((e) => document.documentElement.removeChild(e));

hydrate(<RemixBrowser />, document);

tamperedNodes.forEach((e) => document.documentElement.appendChild(e));

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR: class order is not persisted #3321 - GitHub
When using styled from styled-components for overriding the styles of some Material-UI component, it works on the first load and then breaks ......
Read more >
Styled component, breaks on google chrome - Stack Overflow
Styled component breaks on google chrome when changing the prop (form true to false for example). When props are changed styled component ...
Read more >
Why We're Breaking Up with CSS-in-JS - DEV Community ‍ ‍
Runtime CSS-in-JS libraries work by inserting new style rules when components render, and this is bad for performance on a fundamental level. 2....
Read more >
FAQs - styled-components
styled -components v5 does not introduce any breaking public API changes, and adds the following: Total rewrite of the core stylesheet engine, ...
Read more >
Server Side Rendering - Emotion
import { renderToString } from 'react-dom/server' import App from '. ... The rendered output will insert a <style> tag above each element with...
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