Closed tbgse closed 3 years ago
It's something that cannot be worked around as styled-components
deliberately creates component inside another one 🤷 Fixing this requires a change in either styled-components
or preact
itself. See the issue you referenced linked in your post. The nextjs mentions there are for another issue. The poster for some reason hijacked it.
Thanks for the fast response @marvinhagemeister.
I'm not sure if there was ever any conclusion in the original issue: is this something that you would look into solving in preact? I'm surprised that this issue only started happening after switching from react to preact, so it seems like there must be some difference in how styled-components works with preact? Unless react is simply not outputting these errors.
You mentioned in the issue that This issue can be resolved by adding import "preact/debug" at the top of the main entry file.
But it seems like this is already done in the nextjs plugin that this demo is using?
Please do let me know if there is anything I can do to help looking into this.
@tbgse See https://github.com/preactjs/preact/pull/2816
@marvinhagemeister fantastic, thanks!
Hi,
I've been following this issue https://github.com/preactjs/preact/issues/2574 but could not find any way to fix this myself. I've created a very minimal repo for reproduction that is based off this example and simply does three things:
.babelrc
to include the styled components config for SSR_document.js
to the pages folder, configured as suggested here: https://github.com/vercel/next.js/blob/master/examples/with-styled-components/pages/_document.jsThe result is that when navigating between routes (it does not always happen on initial load, you might have to navigate back and forth a couple of times, or trigger HMR... not 100% sure what triggers the warning exactly), you will see a warning in the console for each styled component that looks like this:
At this point I am unsure if this is a problem with Preact, Next or styled components, but I felt like this repo might be a good place to start.
Example repo: https://github.com/tbgse/preact-next-styled-component