AntD styles missing for a few seconds (pages directory)
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
I'm using nextjs v14.0.3, but still using the pages directory (tried really hard to migrate to the app directory, but unfortunately just too many issues right now in order to migrate)
I'm using SSR for the first time, along with antd v5.3.0, and running into an issue where the styles do not load on the first paint, and so the screen undergoes a massive transformation over the first second or two as the antd styles are loaded. Based on a lot of research and digging, this seems to be related to the fact that antd is using cssinjs. There are guides online about how to correct this exact issue, but unfortunately they are not working for me. I've tried using their extractStyles method in order to pre-generate the CSS to apply to the custom _document.tsx page, but when I do so, all I get is:
Any advice on how to get this to work would be greatly appreciated!
I'm using SSR for the first time, along with antd v5.3.0, and running into an issue where the styles do not load on the first paint, and so the screen undergoes a massive transformation over the first second or two as the antd styles are loaded. Based on a lot of research and digging, this seems to be related to the fact that antd is using cssinjs. There are guides online about how to correct this exact issue, but unfortunately they are not working for me. I've tried using their extractStyles method in order to pre-generate the CSS to apply to the custom _document.tsx page, but when I do so, all I get is:
.data-ant-cssinjs-cache-path{content:"";}, which does not solve the problem.Any advice on how to get this to work would be greatly appreciated!
1 Reply
Spectacled bearOP
This may be on the right track: https://github.com/ant-design/ant-design/issues/39891
Turns out it is incredibly important to use the exact same version of @ant-design/cssinjs for this solution to work
Turns out it is incredibly important to use the exact same version of @ant-design/cssinjs for this solution to work