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
Add support for styled-components v4 #7897
Comments
@kripod could you share what those errors are? Also most helpful is a repo demonstrating the issue, so we can check it out ourselves :) (Also way to be on the bleeding edge 👍 I just saw the announcement, ha!) |
@DSchau Unfortunately, I didn’t copy the error message. However, even after disabling |
I have an issue with v4
This warning pops up only on (every) navigation, e.g. on initial render it is OK. |
Edit: After I fixed flickering css styles with font-awesome and the site was stable, I upgraded styled-components to v4 again... and this time it works without any problem. It's really strange, there's not much difference from what I did now and before. Here's the diff. The only notable things are updated babel plugin and moved font-awesome styles to createGlobalStyle. Not sure if my problem was related to this issue, probably not. Long story short: This repo uses Gatsby v2 with styled-components v4 @kripod Just to clarify: It's |
Having the same problem, so I created a repo for it here The error I'm seeing is:
The exact same repo works fine if you install v3. |
You have Gatsby 1.x which uses older React. You need to use Gatsby 2.x which uses latest React. I don’t think it’s possible to upgrade React in Gatsby without version bump, it’s a breaking change.
… On 8 Sep 2018, at 22:53, Garet McKinley ***@***.***> wrote:
Having the same problem, so I created a repo for it here
The error I'm seeing is:
Unhandled promise rejection TypeError: "React.createContext is not a function"
js http://localhost:8000/commons.js:48548:21
js http://localhost:8000/commons.js:47172:30
__webpack_require__ http://localhost:8000/commons.js:556:12
fn http://localhost:8000/commons.js:87:20
js http://localhost:8000/commons.js:2647:26
__webpack_require__ http://localhost:8000/commons.js:556:12
fn http://localhost:8000/commons.js:87:20
js http://localhost:8000/commons.js:1602:15
__webpack_require__ http://localhost:8000/commons.js:556:12
fn http://localhost:8000/commons.js:87:20
js http://localhost:8000/commons.js:2503:36
__webpack_require__ http://localhost:8000/commons.js:556:12
fn http://localhost:8000/commons.js:87:20
js http://localhost:8000/commons.js:2166:22
__webpack_require__ http://localhost:8000/commons.js:556:12
fn http://localhost:8000/commons.js:87:20
js http://localhost:8000/commons.js:946:15
run http://localhost:8000/commons.js:5674:23
notify http://localhost:8000/commons.js:5691:31
flush http://localhost:8000/commons.js:5134:10
The exact same repo works fine if you install v3.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Woah, that's odd. I swear I had Gatsby v2 installed globally, I'll reinitialize my project and report back. |
|
Ah I see, I missed the line in the readme that mentions using the Ok, so my project is up and running with v2 now and everything seems to work perfectly fine, along with the plugins for SSR. I updated the repo here if maybe @kripod wants to review it to compare and see why his project wasn't working. But from what I can tell, styled-components v4 seems to be a non-issue, phew! 😸 |
Thanks to @tricoder42 and @garetmckinley for examples, I've updated and fixed my own example and it seems like there are no errors or malfunctions so far, only that warning in dev mode. Global styles are working even on navigation. @tricoder42 seems like your example has only one page and if you add another one the warning may occur. |
Yup, I can confirm that what @amankkg said regarding global styles is happening, even when deployed. I created a repo for my new blog here, and I deployed the static site to gh pages here. I have the prism syntax styles in my global styles and when you navigate to a post, the syntax theme does not appear. As soon as you reload the page on the post, the syntax theme shows up. I'm going to add in SSR support to my blog and deploy it to my server to see if the styles persist that way. But as it looks now, global styles are broken when routing on static deployments. edit: the same thing is also happening when the page is reloaded via HMR. As soon as a file is saved, the global styles disappear, and this warning appears:
|
I've been looking into this and I think it's because upon switching pages the previous instance doesn't get unmounted until after the next one has been rendered. I think I'll make a change to when this warning is triggered because we just don't want concurrent renders happening. |
Update your babel plugin please
…On Mon, Sep 10, 2018 at 10:33 AM gi-alec ***@***.***> wrote:
Getting an error in every location I import styled-components:
Module not found: Error: Can't resolve 'styled-components/no-tags'
Sure enough, checking node_modules/styled-components/no-tags/dist, the
folder is empty.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7897 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAiy1qgjd_OJp6_Z4ftacuy-nLMJYwGDks5uZoZOgaJpZM4Wa6sG>
.
|
Rendering the |
On styled-components@4.0.0-beta.2-0 there are no warnings on navigation nor HMR. |
Yeah I haven’t cut a .3 formal beta release yet. Probably later today. Any time you see a version number ending in "-number" that usually means it's a development build for testing and not an official release or beta release.
|
v4.0.0-beta.3 is out which includes the dev warning fix |
General note: |
Yup, latest versions are working great for me! No issues with global styles disappearing during hmr or routing changes. Nicely done @probablyup |
I wonder if this issue with In my case having A solution for this is (from a neighbor thread) just to move that babel plugin to If so, should we mention that in Gatsby tutorial? For now, there is a recommendation to install it as a plain dependency. |
@amankkg update your babel plugin - if you're seeing that issue, you're not using 1.6.4... or possibly using a library that transpiled with an earlier version of the plugin? |
@probablyup I'm on 1.6.4. Error disappeared only after moving this babel plugin to devDependencies. I just followed this styled-components/styled-components#1969 (comment) If this is expected behavior we have to update the Gatsby's SC tutorial. Update:
I don't think so, here is my setup |
Ok so I just ran into another issue when dealing with global styles. It seems like there is a FOUC that is happening on just the global styles. I'm using:
Here's what the issue looks like: https://imgur.com/a/ublAN8R (ignore the gray flickering in the beginning, video encoding issue) [edit: the font flickering is just because it's throttled heavily and the external fonts are loaded very slowly] I throttled the page to make sure it's visible, in real time this only is like a 0.5-1s flicker, but it's very noticeable when on mobile. The individual component styles render instantly (like the purple tag button you see), but the actual global styles (like page margin) do not appear till after the entire page has rendered without them. I don't think I'm using it incorrectly, I have my global styles rendered in my main layout and I also have Everything else has been working great on this latest beta |
@garetmckinley can you provide a reproduction repo or codesandbox? |
Yeah, won't be able to till tomorrow afternoon/evening sometime. The blog I linked to is open source if you wanna look at it, but I totally understand if you'd rather wait for a stripped down repro |
Yeah it's too difficult to chase things down without a minimized example. It's also a double-check on your end to make 100% sure there isn't a library clash happening, etc. |
Yeah np, I'll share a link tomorrow afternoon |
Might be related to #8224 |
The hoisting fix was released in v4.0.0-beta.8 |
Thanks for the update @probablyup! @kripod @garetmckinley @amankkg @tricoder42 can you try upgrading to v4.0.0-beta.8 and check if it fixes the issue for you? |
Resolved my issue 👍 |
Thanks @amankkg This seems to do the trick.
|
We'll be closing this issue as it's resolution is confirmed by @gi-alec and @jameygleason Feel free to open a new one if you still experience this problem 👍 |
It seems like this is broken now? @kakadiadarpan Here are my dependencies
Doing this
has no effect.. this is what I see on the DOM
Here's a sandbox https://codesandbox.io/s/jzjw9ojlxy |
You have to put |
@probablyup it is. See my sandbox ( |
Crap, used |
Summary
I tried to update a project to styled-components@next, but exceptions get thrown during
gatsby develop
.The text was updated successfully, but these errors were encountered: