Refactored and cleaned up code
This commit is contained in:
14
weather-ui/src/lib/AntdRegistry.tsx
Normal file
14
weather-ui/src/lib/AntdRegistry.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';
|
||||
import type Entity from '@ant-design/cssinjs/es/Cache';
|
||||
import { useServerInsertedHTML } from 'next/navigation';
|
||||
|
||||
const StyledComponentsRegistry = ({ children }: { children: React.ReactNode }) => {
|
||||
const cache = React.useMemo<Entity>(() => createCache(), [createCache]);
|
||||
useServerInsertedHTML(() => <style id='antd' dangerouslySetInnerHTML={{ __html: extractStyle(cache, true) }} />);
|
||||
return <StyleProvider cache={cache}>{children}</StyleProvider>;
|
||||
};
|
||||
|
||||
export default StyledComponentsRegistry;
|
||||
Reference in New Issue
Block a user