File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
packages/doom/src/runtime/components Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 1- import type MasonryLayout from 'masonry-layout'
1+ import type { Options } from 'masonry-layout'
22import { useLayoutEffect , useRef , type HTMLAttributes } from 'react'
33
44export interface MasonryProps extends HTMLAttributes < HTMLDivElement > {
5- options ?: MasonryLayout . Options
5+ options ?: Options
6+ }
7+
8+ let MasonryLayout : typeof import ( 'masonry-layout' )
9+
10+ if ( typeof window !== 'undefined' ) {
11+ MasonryLayout = ( await import ( 'masonry-layout' ) ) . default
612}
713
814export const Masonry = ( { options, ...props } : MasonryProps ) => {
@@ -13,11 +19,7 @@ export const Masonry = ({ options, ...props }: MasonryProps) => {
1319 return
1420 }
1521
16- // eslint-disable-next-line @typescript-eslint/no-require-imports
17- const masonry = new ( require ( 'masonry-layout' ) as typeof MasonryLayout ) (
18- ref . current ,
19- options ,
20- )
22+ const masonry = new MasonryLayout ! ( ref . current , options )
2123
2224 return ( ) => {
2325 masonry . destroy ?.( )
You can’t perform that action at this time.
0 commit comments