mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 01:01:38 +00:00
✨ Update sandpack ssr
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { Sandpack, SandpackProps } from '@codesandbox/sandpack-react';
|
||||
import { Sandpack, SandpackProps } from '@codesandbox/sandpack-react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import useInView from 'lib/hooks/useInView';
|
||||
|
||||
interface Props extends SandpackProps {}
|
||||
|
||||
@ -8,17 +7,13 @@ const RUASandpack = ({ ...rest }: Props) => {
|
||||
const { systemTheme, theme } = useTheme();
|
||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||
|
||||
const { ref, inView } = useInView();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="my-2 min-h-[402px]" ref={ref}>
|
||||
{inView && (
|
||||
<Sandpack
|
||||
{...rest}
|
||||
theme={currentTheme === 'dark' ? 'dark' : 'light'}
|
||||
/>
|
||||
)}
|
||||
<div className="my-2 min-h-[402px]">
|
||||
<Sandpack
|
||||
{...rest}
|
||||
theme={currentTheme === 'dark' ? 'dark' : 'light'}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
Reference in New Issue
Block a user