Skip to content
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

Changing document.title throws the error "Cannot find a StyleSheet instance" #4040

Closed
Msirkovsky opened this issue Jun 14, 2023 · 5 comments
Closed

Comments

@Msirkovsky
Copy link

Hi all,

it's super weird but when I use this code:

document.title = "any string";

and then rerender any component, it causes the following error:

Error: An error occurred. See https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/errors.md#10 for more information.
    at new e (2.b5a40e5c.chunk.js:1:127816)
    at $ (2.b5a40e5c.chunk.js:1:129595)
    at Object.insertRules (2.b5a40e5c.chunk.js:1:132663)
    at t.inject (2.b5a40e5c.chunk.js:1:136095)
    at t.generateAndInjectStyles (2.b5a40e5c.chunk.js:1:139513)
    at e.generateAndInjectStyles (2.b5a40e5c.chunk.js:1:144292)
    at e.renderInner (2.b5a40e5c.chunk.js:1:143248)
    at Rs (2.b5a40e5c.chunk.js:1:2097342)
    at Pc (2.b5a40e5c.chunk.js:1:2079580)
    at Sc (2.b5a40e5c.chunk.js:1:2079505)

I'm using CRA and styled-components v. 4.4.1.

I've also noticed that the styled-components adds the element style into the title attribute in the head section.

<head>
<title>Test<style data-styled="" data-styled-version="4.4.1">
/* sc-component-id: sc-bwzfXH */
...
</style></title>
...

Thanks.

@usercao
Copy link

usercao commented Jun 16, 2023

Why not upgrade to version 6.0 and try again? This may be caused by an older version.

@lordvic4real
Copy link

I will like to work on this issue

@lordvic4real
Copy link

Why not upgrade to version 6.0 and try again? This may be caused by an older version.

You have a good point

@Msirkovsky
Copy link
Author

Hi, I've upgraded to v5.3.11 and the issue still persists.
image

@quantizor
Copy link
Contributor

Should be fixed in https://github.com/styled-components/styled-components/releases/tag/v6.0.0-rc.6, thanks for using styled-components!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants