-
-
Notifications
You must be signed in to change notification settings - Fork 53.5k
Closed
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
What is expected?
Also add the config property to the ConfigProvider
to render on SSR instead of using updateCSS
.
Maybe something like this:
const ConfigProvider: React.FC<ConfigProviderProps> & {
ConfigContext: typeof ConfigContext;
SizeContext: typeof SizeContext;
config: typeof setGlobalConfig;
} = props => {
React.useEffect(() => {
if (props.direction) {
message.config({
rtl: props.direction === 'rtl',
});
notification.config({
rtl: props.direction === 'rtl',
});
}
}, [props.direction]);
// getThemeVariables() -> return ':root { --primary-color: #00a; ... }
const variables = props.config.theme ? getThemeVariables(getGlobalPrefixCls(), props.theme) : null
return (
<>
{variables && <style>{variables}</style>}
<LocaleReceiver>
{(_, __, legacyLocale) => (
<ConfigConsumer>
{context => (
<ProviderChildren
parentContext={context}
legacyLocale={legacyLocale as Locale}
{...props}
/>
)}
</ConfigConsumer>
)}
</LocaleReceiver>
</>
);
};
If this is not possible, at least export a function where we can get the colors object created in ./components/config-provider/cssVariables.tsx
to manually add it to the code on SSR.
ant-design/components/config-provider/cssVariables.tsx
Lines 87 to 89 in 5903f40
const cssList = Object.keys(variables).map( | |
key => `--${globalPrefixCls}-${key}: ${variables[key]};`, | |
); |
What is actually happening?
Cant use it and on SSR the colors will not be added.
Environment | Info |
---|---|
antd | 4.18.7 |
React | 17 |
System | Mac OS |
Browser | - |
Connected to issue: #34100
zombieJ