UNPKG

@alauda/doom

Version:

Doctor Doom making docs.

22 lines (21 loc) 894 B
import { jsx as _jsx } from "react/jsx-runtime"; import { NoSSR } from '@rspress/core/runtime'; import { lazy, Suspense, useLayoutEffect, useRef, } from 'react'; const LazyMasonry = lazy(() => import('masonry-layout').then(({ default: MasonryLayout }) => { const Masonry = ({ options, ...props }) => { const ref = useRef(null); useLayoutEffect(() => { if (!ref.current) { return; } const masonry = new MasonryLayout(ref.current, options); return () => { masonry.destroy?.(); }; }, [options]); return _jsx("div", { ref: ref, ...props }); }; return { default: Masonry }; })); export const Masonry = ({ options, ...props }) => (_jsx(NoSSR, { children: _jsx(Suspense, { children: _jsx(LazyMasonry, { options: options, ...props }) }) })); export default Masonry;