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

Resolve error with invalid context of styled-components #2

Open
macku opened this issue Feb 16, 2018 · 4 comments
Open

Resolve error with invalid context of styled-components #2

macku opened this issue Feb 16, 2018 · 4 comments
Labels
bug Something isn't working

Comments

@macku
Copy link
Owner

macku commented Feb 16, 2018

When running test that is using STYLED_COMPONENTS as a renderer there is a problem with React context:

Failed context type: Invalid context `__styled-components-stylesheet__` supplied to `Component`.
@macku macku added the bug Something isn't working label Feb 16, 2018
@michalg42
Copy link

michalg42 commented Mar 14, 2018

Most probably it's caused by different versions of styled-components used in project and jest-puppe-shots, at least it was a case in my situation, when I changed styled-components in jest-puppe-shots to peerDependency it started to use the one from root of my project and it no longer shows this error.

But it lead to new problem, in new version of styled-components directory lib has been completely removed so there is error in renderer of styled components. Here is issue about this problem: styled-components/styled-components#1483

@michalg42
Copy link

I downloaded this project and tried to fixed it by myself, but I don't know how to build this this project so I can't test it with real app, I'm quite new to lerna and this kind of stuff. :(

Fixing it is quite simple, styled-components needs to be moved to peerDependencies and at least "3.0.0" (as it had some breaking changes) and one line in styled components renderer, I could create PR but as I said, I can't test it with real app so I'm not sure if it works correctly...

@macku
Copy link
Owner Author

macku commented Mar 23, 2018

Sounds good. You can create a Pull Requests if you have some code and I can test it later this weekend.

As for testing development version:

  1. Run npm install in the root directory
  2. Next, run npm run bootstrap
  3. In terminal go to the cd packages/jest-puppe-shots and run npm link
  4. Link the rest of the packages from the directory: cd ../jest-puppe-shots-env; npm link; cd ../jest-puppe-shots-preset; npm link
  5. Now you can start using all the packages locally in your test project. Just navigate to the project directory and in a terminal run:
    npm link jest-puppe-shots jest-puppe-shots-env jest-puppe-shots-preset

If you will make changes in the puppe-shots project all the change should be visible in your test project.

If you would like to remove the linked packages, simple run npm unlink jest-puppe-shots jest-puppe-shots-env jest-puppe-shots-preset.

Let me know if this helped.

@slangberg
Copy link

Any news on this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants