Styles unsyncing (?) with NextJS
See original GitHub issueHi everyone,
I’m struggling for more than 48h with this issue, so I decided to overpass the feeling this is a specific issue from my side and to leverage your experience and brains as mine is 🤯
FYI, my setup is NextJS + TypeScript + Chakra UI.
I have some kind of “styling unsyncing” that appeared recently, and I’m unable to find the cause.
What I noticed though is the weird amount of styles piling up. My first question would be: is this normal? The subsidiary question would be: what would be the cause?
Another strange thing is when I’m hovering a button, the styling of the drawer breaks:
And finally, from one page transition to another (using next/link
), scroll is (sometimes…) disabled/not working.
Unfortunately, I can’t share the repo as it is private and not mine. I tried to reproduce the issue in a sandbox without success…
I know animated gif is not the greatest to help debugging, but I’m willing to share any code snippet you would suspect being the problem ! 🙏 🙏
🌍 System information
Software | Version(s) |
---|---|
Chakra UI | 1.3.3 |
Browser | Chrome |
Operating System | MacOS |
Issue Analytics
- State:
- Created 2 years ago
- Comments:15
Top GitHub Comments
@binajmen Based on my experience with Chakra and NextJs
Yes this is normal.
The Styles that we see in the dev tools are from Chakra’s default theme
If you have custome functional component that wraps the link
<a></a>
then you need to pass the ref fromnext/link
via the propspassHref
- Read about this on ref forwarding in the next docsTo reproduce your problem have you tried this template ? NextJS TypeScript CodeSandbox template
I have a project that uses react-select and Have a similar problem, it is definitely related to react-select and there emotion package been in conflict with chakra-ui. Basically the pages that use react-select are working fine, if you go to a page that doesn’t use it, still works, but if you reload that page, the style breaks. I didn’t find a solution yet to use react-select with chakra-ui and next-js.
PS. it only happen on yarn build, works on yarn dev