Skip to content

Not working under Svelte 5 #109

@stormwarning

Description

@stormwarning

After upgrading to Svelte v5, I get an error:

TypeError: Class constructor SvelteMasonryGrid cannot be invoked without 'new'

I've tried wrapping the component in createClassComponent (although deprecated) but I still get the same error.

My wrapper component
<script>
import { onDestroy, onMount } from 'svelte'
import { createClassComponent } from 'svelte/legacy'

import { MasonryGrid } from '@egjs/svelte-grid'

/**
 * @typedef {Object} Props
 * @property {number} [column]
 * @property {string} [align]
 * @property {number} [gap]
 * @property {import('svelte').Snippet} [children]
 */

/** @type {Props} */
let { column = 2, align = 'stretch', gap = 16, children } = $props()

let container
let gridInstance

onMount(() => {
	const GridComponent = createClassComponent({
		component: MasonryGrid,
		target: container,
		props: {
			column,
			align,
			gap,
		},
	})

	gridInstance = GridComponent
})

onDestroy(() => {
	if (gridInstance && gridInstance.destroy) {
		gridInstance.destroy()
	}
})
</script>

<div bind:this={container}>
	{@render children?.()}
</div>

Any help is greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions