question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic Theme breakes on SSR

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Steps to reproduce

npx create-next-app@latest --ts npm i antd

Then change _app.tsx and add

import { ConfigProvider } from 'antd'

ConfigProvider.config({
  theme: {
    primaryColor: '#f00'
  }
})

What is expected?

Build successfull

What is actually happening?

Build fails with:

ReferenceError: document is not defined
  at getContainer (./node_modules/rc-util/lib/Dom/dynamicCSS.js:32:14)
  at updateCSS (./node_modules/rc-util/lib/Dom/dynamicCSS.js:90:19)
  at registerTheme (./node_modules/antd/lib/config-provider/cssVariables.js:96:29)
  at Function.setGlobalConfig [as config] (./node_modules/antd/lib/config-provider/index.js:87:37)
  at eval (webpack-internal:///./pages/_app.tsx:14:50)
  at Object../pages/_app.tsx (./.next/server/pages/_app.js:22:1)
  at __webpack_require__ (./.next/server/webpack-runtime.js:33:42)
  at __webpack_exec__ (./.next/server/pages/_app.js:64:39)
  at ./.next/server/pages/_app.js:65:28
  at Object.<anonymous> (./.next/server/pages/_app.js:68:3)
Environment Info
antd 4.18.7
React 17
System Mac OS
Browser -

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wuifdesigncommented, Feb 18, 2022

but this is not the optimal way, maybe you can expose a funtion that generates the required CSS Styles. So we can run this at SSR and inject the styles ourself?

something that we can get this on SSR:

:root {
    ${cssList.join('\n')}
  }

so we can pass them as props and inject it via:

<style>{props.themeStyles}</style>
0reactions
IRediTOTOcommented, Aug 25, 2022

but this is not the optimal way, maybe you can expose a funtion that generates the required CSS Styles. So we can run this at SSR and inject the styles ourself?

something that we can get this on SSR:

:root {
    ${cssList.join('\n')}
  }

so we can pass them as props and inject it via:

<style>{props.themeStyles}</style>

I love this way, can you please share the code to do that ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a page break to a paginated report (Report Builder)
To add a page break to a data region · On the design surface, right-click the corner handle of the data region and...
Read more >
Page refresh break styles on Nextjs production app
This way you will force it to create styles only after the client-side is loaded. Guide to disable SSR for a component: https://nextjs.org/docs/ ......
Read more >
SSR Related Links - Chevy SSR Club
Web links for repair, parts, accessories, etc…. Aftermarket and OEM Accessories and Parts – Simple Engineering – Source for parts and accessories.
Read more >
1PZ SSR-SD2 Brake Pads Replacement for SDG SSR 50cc ...
Buy 1PZ SSR-SD2 Brake Pads Replacement for SDG SSR 50cc 70cc 110cc 125cc 140cc Thumpstar Coolster Orion Demon Stomp BSE Kayo Lifan YX...
Read more >
2006 Chevy SSR: A seriously sporty ride - The Virginian-Pilot
It's the 2006 Chevrolet SSR sport pickup, created by General ... disc brakes with four-wheel antilock system and dynamic rear proportioning.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found