Several instances of 'styled-components' initialized in this application.

See original GitHub issue

Description

Not sure if this would be classified as a bug, but should the default npx init provide the following warning when using it on the default Nextjs example?

It looks like there are several instances of ‘styled-components’ initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason. See https://s-c.sh/2BAXzed for more info.

Steps to reproduce

  1. Create a new directory
  2. execute npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"
  3. cd nextjs-blog
  4. execute npx @tinacms/cli@latest init and wait

Setting up Tina… Installing Tina packages. This might take a moment… ✅ Adding _app.js … ✅ Adding a content folder… ✅ Tina setup done ✅ Start your dev server with yarn tina-dev and go to http://localhost:3000/demo/blog/HelloWorld to check it out the page that was created for you Enjoy Tina 🦙 !

  1. execute yarn tina-dev and check your browser console at http://localhost:3000/

Expected result

I assume that we shouldn’t have issue with several instances of styled-components.

Actual result

image

Environment

Tinacms Package Versions

  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "tina-dev": "yarn tinacms server:start -c \"next dev\"",
    "tina-build": "yarn tinacms server:start -c \"next build\"",
    "tina-start": "yarn tinacms server:start -c \"next start\""
  },
  "dependencies": {
    "@tinacms/cli": "^0.57.2",
    "next": "latest",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "styled-components": "^5.3.3",
    "tinacms": "^0.59.0"
  }
}

Tools

Tool Version
Chrome Version 96.0.4664.45 (64-bit)
os Windows 10 Pro
node 14.15.4
npm 6.14.10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffsee55commented, Jan 5, 2022

This is a strange one, but we’re moving away from styled components for the rich text editor. I expect there are some oddities around how some of our dependencies in plate are loading styled-components. We’re confident that this isn’t manifesting in any actual bugs, just a false positive warning. @cjmcintyre bare with us as this might be a couple of weeks before this is fully refactored out.

1reaction
logan-andersoncommented, Dec 20, 2021

@jeffsee55 Still seeing this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Several instances of 'styled-components' initialized in ... - GitHub
Error: Trying to insert a new style tag, but the given Node is unmounted! Are you using a custom target that isn't mounted?...
Read more >
Several instances of 'styled-components' initialized in CRA ...
I was facing the same issue and I solved it by moving all my styled components inside remote apps and exposed them from...
Read more >
The quick and dirty way to resolve Styled-Components ...
It looks like there are several instances of 'styled-components' initialized in this application... This warning may be accompanied by a tangled ...
Read more >
FAQs - styled-components
It looks like there are several instances of "styled-components" initialized in this application. This may cause dynamic styles not rendering properly, ...
Read more >
Howto Fix Multiple styled-component Instances - MYRTANA.SK
To fix multiple instances being loaded, set up customize-cra and add this to the config.overrides.js . AFAIK it aliases styled-components to be loaded...
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