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

warning: You are loading @emotion/react when it is already loaded. #465

Closed
ellen-localley opened this issue Apr 25, 2022 · 3 comments
Closed
Labels

Comments

@ellen-localley
Copy link

Hi,
I'm already using emotion in my app. This warning has appeared when the module was installed and runned.

You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used. emotion-react.browser.esm.js:353
./node_modules/react-spinners/node_modules/@emotion/react/dist/emotion-react.browser.esm.js @ emotion-react.browser.esm.js:353

package.json

  "@emotion/react": "11.7.1",
  "@emotion/styled": "11.6.0",
...
  "@babel/plugin-transform-react-jsx": "7.17.3",
  "@babel/preset-env": "7.16.11",
  "@emotion/babel-plugin-jsx-pragmatic": "0.1.5",

.babelrc

{
    "presets": ["@babel/preset-react", "@babel/preset-env"],
    "plugins": [
     [
         "@emotion/babel-plugin-jsx-pragmatic",
         {
           "export": "jsx",
           "import": "__to_avoid_prepending_/** @jsxImportSource @emotion/react */",
           "module": "@emotion/react"
         }
       ],
       [
         "@babel/plugin-transform-react-jsx",
         {
           "pragma": "__to_avoid_prepending_/** @jsxImportSource @emotion/react */"
         }
       ]
    ]
}

tsconfig.json

...
  "jsxImportSource": "@emotion/react",
...

and my component is like that:

import SyncLoader from 'react-spinners/SyncLoader';

export const DataLoading = () => {
	return <SyncLoader size={5} />;
};

Can I solve this problem?

@davidhu2000
Copy link
Owner

i think i need to move emotion to peerDeps instead of deps

@davidhu2000 davidhu2000 added the bug label May 3, 2022
@davidhu2000
Copy link
Owner

altho that can cause issues with existing users. Need to think of a way to get rid of emotion as a dependency

@davidhu2000
Copy link
Owner

going to merge this with #208

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

No branches or pull requests

2 participants