Files
DefectingCat.github.io/components/RUA/RUASandpack.tsx
DefectingCat 77c01e168d Add new post toc
fix useLayoutEffect warnning
2022-08-11 18:06:26 +08:00

23 lines
540 B
TypeScript

import { Sandpack, SandpackProps } from '@codesandbox/sandpack-react';
import { useTheme } from 'next-themes';
interface Props extends SandpackProps {}
const RUASandpack = ({ ...rest }: Props) => {
const { systemTheme, theme } = useTheme();
const currentTheme = theme === 'system' ? systemTheme : theme;
return (
<>
<div className="my-2 min-h-[402px]">
<Sandpack
{...rest}
theme={currentTheme === 'dark' ? 'dark' : 'light'}
/>
</div>
</>
);
};
export default RUASandpack;