Valexr / Slidy

📸 Sliding action script
https://valexr.github.io/Slidy/
MIT License
316 stars 13 forks source link

@slidy/svelte - TypeError #125

Closed astroanax closed 2 months ago

astroanax commented 3 months ago

Attempting the following - (exactly same as usage linked at https://github.com/Valexr/Slidy/tree/3784f86e7d8f517ff4665ac9eda2be06621c3161/packages/svelte#usage)

<script>
                import { Slidy } from "@slidy/svelte";
        const images = [
            {
                id: 1,
                width: 800,
                height: 1200,
                src: "static/img/1.jpg",
            }
        ];
</script>

<Slidy {images} />

results in -

TypeError: Cannot read properties of undefined (reading 'length')
    at /home/astroanax/dev/unwired-web2/node_modules/@slidy/svelte/dist/components/Slidy/Slidy.svelte:39:21
    at Object.$$render (/home/astroanax/dev/unwired-web2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at eval (/home/astroanax/dev/unwired-web2/src/routes/+page.svelte:20:519)
    at Object.$$render (/home/astroanax/dev/unwired-web2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at Object.default (/home/astroanax/dev/unwired-web2/.svelte-kit/generated/root.svelte:46:41)
    at /home/astroanax/dev/unwired-web2/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte:5:41
    at Object.$$render (/home/astroanax/dev/unwired-web2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at /home/astroanax/dev/unwired-web2/.svelte-kit/generated/root.svelte:45:40
    at $$render (/home/astroanax/dev/unwired-web2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at Object.render (/home/astroanax/dev/unwired-web2/node_modules/svelte/src/runtime/internal/ssr.js:164:17)

I think it's related to https://github.com/Valexr/Slidy/blob/89bddeb0a1a5ea44f4898625b9922b8c0ba67c26/packages/svelte/src/components/Slidy/Slidy.svelte#L36

Only my version of Slidy.svelte (3.4.4), the line is export let slides;, while on the git repo, it is export let slides: SlidyOptions["slides"]; even though both are the same versions (???)

On checking the code of the package at https://www.npmjs.com/package/@slidy/svelte?activeTab=code it is the same export let slides; which I don't understand because the npm page says it is version 3.4.4

Valexr commented 3 months ago

In component API we have slides property. You need to use it.

<Slidy slides={images} />